Skip to content

Instantly share code, notes, and snippets.

@34j
Created January 18, 2023 09:22
Show Gist options
  • Save 34j/0da0808be2d1cea156665722476d51bd to your computer and use it in GitHub Desktop.
Save 34j/0da0808be2d1cea156665722476d51bd to your computer and use it in GitHub Desktop.
physics-materialderivative.sty
\RequirePackage{xparse}
\DeclareDocumentCommand\materialderivative{ s o g d() }
{ % Total materialderivative
% s: star for \flatfrac flat materialderivative
% o: optional n for nth materialderivative
% g: optional (f in df/dx)
% d: long-form d/dx(...)
\IfBooleanTF{#1}
{\let\fractype\flatfrac}
{\let\fractype\frac}
\IfNoValueTF{#3}
{
\IfNoValueTF{#4}
{\fractype{\mathrm{D} \IfNoValueTF{#2}{}{^{#2}}}{\mathrm{D} t\IfNoValueTF{#2}{}{^{#2}}}}
{\fractype{\mathrm{D} \IfNoValueTF{#2}{}{^{#2}}}{\mathrm{D} t\IfNoValueTF{#2}{}{^{#2}}} \argopen(#4\argclose)}
}
{\fractype{\mathrm{D} \IfNoValueTF{#2}{}{^{#2}} #3}{\mathrm{D} t\IfNoValueTF{#2}{}{^{#2}}}}
}
\DeclareDocumentCommand\mdv{}{\materialderivative} % Shorthand for \materialderivative
@34j
Copy link
Author

34j commented Jan 18, 2023

\mdv{f} = \frac{\mathrm{D} f}{\mathrm{D} t}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment