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
[Loading MPS to PDF converter (version 2006.09.02).]
)
! Missing \endcsname inserted.
<to be read again>
                   \def
l.15 }
      {}

How can I fix this problem?

Tags : minted etoolbox


Related Questions



REVTex-like affiliation& author command

Updated March 20, 2016 08:09 AM


Why won't my boolean work correctly?

Updated July 08, 2016 08:01 AM

Less-than string comparison like \ifstrequal

Updated June 30, 2017 15:23 PM