tags:

views:

25

answers:

1

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 the command is called, is it possible?

+3  A: 

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.

Ivan Andrus
Thanks, it works (with \edef). I had tried with \expandafter since the other question was mine also... But it didn't work, I don't really understand how \expandafter works.
flaflamm
Ah, I didn't realize the other question was yours. And yes, \expandafter can be a pain.
Ivan Andrus