I frequently find that I want to make a macro, say a derivative macro for example with the following syntax:
\def\dd #1;#2;{ return... }
However, I want it to check if it is inline math such as when math is wrapped between two dollar symbols $ ... $ or if it is in a block of math such as an \[...\] or align or equation environment. If the latter is the case then I want it to typeset
\frac{\mathrm{d} #1 }{\mathrm{d} #2 }
if it is inline math such as $ ... $ then I want it to typeset
\mathrm{d} #1 / \mathrm{d} #2.
How can I do this?
