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
\emptyand\@emptyin LaTeX and, perhaps, suggest a better solution for my problem?
\emptyremains for historic reasons; probably at the timelplain.texwas written it was called\emptyas inplain.texand then\@emptywas added for uniformity. Actually\emptyis useful for avoiding\makeatletterand\makeatothersometimes. – egreg Sep 18 '11 at 09:44polyglossiapkg with option[babelshorthands]and\setdefaultlanguage{russian}. It seems to redefine\emptysince withoutpolyglossiaboth\emptyand\@emptyvariants take the branch [b2] wich is not what I want. – Igor Kotelnikov Sep 18 '11 at 10:35\spaceso why not have\empty? I mean, why having\@emptyat all? LaTeX doesn't define a\@spaceas well. – Martin Scharrer Sep 18 '11 at 15:23