微量元素

微量元素

我剛剛創建了一個回答使用臨時變數並認為使用,\write\@auxout來確定範圍是個好主意\begingroup\endgroup由於某種原因,這會導致:

!未定義的控制序列。
<寫入> \臨時變數

微量元素

\documentclass{article}

\makeatletter
\newcommand{\abc}{%
    \begingroup%
    \newcommand\tempvariable{\relax}%
    \write\@auxout{\tempvariable}%
    \endgroup%
}
\makeatother

\begin{document}
    Why isn't this working???
    \abc 

\end{document}

為什麼會發生這種情況?

答案1

添加\immediate應該有幫助:

\documentclass{article}

\makeatletter
\newcommand{\abc}{%
   \begingroup%
    \newcommand\tempvariable{\relax}%
%    \write\@auxout{\tempvariable}%
\immediate \write\@auxout{\tempvariable}%
    \endgroup%
}
\makeatother

\begin{document}
    Why isn't this working???
    \abc 

\end{document}

我可以從連結中的回答中看到,您知道 command \immediate,所以可能不需要額外的評論。

相關內容