I want to use etoolbox's toggles to achieve the following: In the preamble a toggle is created, during typesetting the document its value might change and at the end I want to write the value to the aux file to access it next time. However, setting toggles in the aux file does not seem to work, as the following MWE illustrates:
\documentclass{minimal}
\usepackage{etoolbox}
\newtoggle{testtoggle}
\begin{document}
\makeatletter
\immediate\write\@auxout{\noexpand\toggletrue{testtoggle}}
\makeatother
\iftoggle{testtoggle}{true}{false}
\end{document}
After running this, the aux file contains
\relax
\toggletrue {testtoggle}
as it should. However, in the document created it says "false" instead of "true". How can this be fixed?
The same problem also occurs when I use \newif
statements instead of toggles.
minimal
class!