josephwright / etoolbox

Tool-box for LaTeX programmers using e-TeX
LaTeX Project Public License v1.3c
41 stars 7 forks source link

"You can't use a prefix with `\begingroup' " #29

Open urrameu opened 4 years ago

urrameu commented 4 years ago

Hi,

Writing the wrong combination of \providebool + \global\booltrue to the aux file may cause the error mentioned in the title.

The MWE below crashes on the second pass, but uncommenting the \def\blah{} lines makes the problem go away (I got this from a remark by Joseph Wright somewhere on tex.stackexchange.com).

Thanks!

\documentclass{article}
\usepackage{etoolbox}

\makeatletter
\AtEndDocument{ % or AtBeginDocument
  \immediate\write\@mainaux{\providebool{myboolI}}
  \immediate\write\@mainaux{\global\booltrue{myboolI}}
  %\immediate\write\@mainaux{\string\def\string\blah{}}

  \immediate\write\@mainaux{\providebool{myboolII}}
  \immediate\write\@mainaux{\global\booltrue{myboolII}}
  %\immediate\write\@mainaux{\string\def\string\blah{}}
}
\makeatother

\begin{document}\end{document}