
Acabo de crear unrespuestaque usa una variable temporal con \write\@auxout
y pensé que sería una buena idea ampliar el alcance con \begingroup
, \endgroup
. Por alguna razón, esto resulta en:
! Secuencia de control Indefinido.
<escribir> \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}
¿Por qué sucede esto y cómo puedo solucionarlo?
Respuesta1
Agregar \immediate
debería ayudar:
\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}
Puedo ver en su respuesta del enlace que conoce el comando \immediate
, por lo que probablemente no sea necesario ningún comentario adicional.