开发者

Is it possible to ask Latex to evaluate a command

开发者 https://www.devze.com 2023-01-05 02:04 出处:网络
This code: \\begin{enumerate} \\item Item One \\def\\commandOne{\\alph{enumi} : One} \\item Item Two \\def\\commandTwo{\\alph{enumi} : Two}

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消