4

I just created an answer that uses a temporary variable with \write\@auxout and thought it would be good idea to scope with \begingroup, \endgroup. For some Reason this results in:

! Undefined control sequence.
<write> \tempvariable

MWE

\documentclass{article}

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

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

\end{document}

Why is this happening and how can I fix this?

someonr
  • 8,531

1 Answers1

5

Adding \immediate should help:

\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}

I can see from your anwer from the link, that you know command \immediate, so probably no additional comment is needed.

  • Thx you, I must be blind ;). Anyone else with this problem might want to read this http://tex.stackexchange.com/questions/115932/on-the-basics-of-writing-to-reading-from-auxiliary-files-aux-toc-etc – someonr Dec 30 '13 at 05:07