# iftoggle with minted

by asante   Last Updated November 08, 2018 22:23 PM

I have a problem with the minted package in combination with etoolbox's iftoggle. It should be related (or basically be the same error) to this beamer question: minted environment in frame causes error but the there stated solution (using a fragile frame) cannot be applied in this way to a standard document.

The following MWE gives an error when \toggletrue{test}:

\documentclass{report}%
\usepackage{etoolbox}
\newtoggle{test}
\toggletrue{test}
\usepackage{minted}
\begin{document}
\iftoggle{
\begin{minted}
test
\end{minted}
}{}
test
\end{document}


The error is

(./mwe.aux)
(/usr/local/texlive/2016/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
)
! Missing \endcsname inserted.