This code:
\begin{enumerate}
\item Item One \def\commandOne{\alph{enumi} : One} \item Item Two \def\commandTwo{\alph{enumi} : Two} \item \commandOne, \commandTwo \end{enumerate}
Gives this output:
Item One
Item Two c : One, c : Two
I want that Latex evaluate \alph{enumi} when the command is defined instead of when th开发者_如何学Pythone command is called, is it possible?
Instead of \def
, use \edef
which expands at the time of definition (see also \gdef
and \xdef
). This can of course cause problems if you want parts of it not expanded. For those cases you can use \expandafter
as shown in this answer.
精彩评论