I want to elaborate a command that would print differently simple differential dx
and multidimensional differential d^3x
. For this purpose I invented the command \dif
with one optional argument. It is defined as follows:
\newcommand{\dif}[1][]{%
\def\@tmp@a{#1}%
\ifx\@tmp@a\@empty
[b1]\mathrm{d}
\else
[b2]\mathrm{d}^{#1}{} \!
\fi
}
Here [b1] and [b2] are added for debugging. Branch [b1] is intended for the case when the command is called without any argument, e.g. \dif{x}
. Second branch [b2] should be taken in case where, e.g., the command \dif[3]{x}
is used to print d^3x
. The definition, shown above, seems to work fine. However, if \@empty
is substituted with \empty
first branch is always ignored.
The command \empty
is explained in The TeXBook, so that initially I tried it for this code and only occasionally reverted to \@empty
having remembered a post at this site where it was said that the \end
command of Plain TeX is redefined to \@@end
in LaTeX.
Can somebody explain what is the difference between
\empty
and\@empty
in LaTeX and, perhaps, suggest a better solution for my problem?