0

In this answer, egreg uses

\NewDocumentCommand{\refprefix}{m}{%
  \ifinproofref\else #1\fi
}

The command \refprefix is part of code that's written to the aux file. Defining the command with

\newcommand{\refprefix}[1]{%
  \ifinproofref\else #1\fi
}

does not work, apparently, because \refprefix is already expanded on writing the aux file.

Why is that so, and which other definition-like commands behave in what way in this context?

1

1 Answer 1

3

The difference in this context is that \NewDocumentCommand uses e-tex \protected\def so the command does not expand in a \write. You could use \NewExpandableDocumentCommand to define an unprotected version. Similarly in classic latex, you could use \DeclareRobustCommand to define a command that does not expand (using LaTeX \protect mechanism rather than \protected).

Not the answer you're looking for? Browse other questions tagged .