The cool
package offers commands for writing partial derivates (and a lot of other stuff).
A short example:
\documentclass{article}
\usepackage{cool}
\begin{document}
\begin{equation*}
\pderiv{f}{x} \qquad
\pderiv[2,3]{f}{x,y} \qquad
\pderiv[1,n,4]{f}{x,y,z}
\end{equation*}
\end{document}
Note
By default the last two of those will not work, as there is a bug in the package. This can be fixed by changing a \def
to \edef
in line 2059 of cool.sty
, see Basic use of derivative with cool package fails with "Missing \endcsname inserted"
The best approach is to make the numerator variable optional:
\newcommand{\pder}[2][]{\frac{\partial#1}{\partial#2}}
Now \pder[f]{x}
and \pder{x}
will work as you wish.
A solution that uses the syntaxes \pder{f}{x}
and \pder{x}
is
\makeatletter
\DeclareRobustCommand{\pder}[1]{%
\@ifnextchar\bgroup{\@pder{#1}}{\@pder{}{#1}}}
\newcommand{\@pder}[2]{\frac{\partial#1}{\partial#2}}
\makeatother
which however is quite risky, because an open brace after \pder{x}
will be mistaken for the start of the second argument (spaces are ininfluent). All in all, the optional argument path seems better.
If you don't plan to often use \pder
inside moving arguments, \DeclareRobustCommand
can be changed into \newcommand
, but the command would be fragile and so needing \protect
in front of it when in moving arguments.
Best Answer
That picture looks like