My code looks like this
\documentclass{article}
\usepackage{environ}
\newcommand{\showsolution}{1}
\NewEnviron{mysolution}{
\if\showsolution1
\fbox{\BODY}
\fi}
\begin{document}
\begin{mysolution}
\begin{verbatim}
code code code
\end{verbatim}
\end{mysolution}
\end{document}
where the solution environment is created with the NewEnviron package as I want to display the solution depending on an if statement. However, if I now want to put code inside my solution by using verbatim I get the runaway argument / Paragraph ended before \next was complete.
Edit: with the MWE above the error changes to missing \item. However, commenting out the verbatim inside the error disappears so it is still the same issue eventhough the error changed.
I guess the solution is something similar to the fragile option in beamer's frame environment but I dont know wether there are similar options for the environ package. So how can I place verbatim text (or at least code) inside an if statement?




\ifstatement yet. And you environment ends withsolution, not withmysolution;-) – May 02 '17 at 17:43\fbox{\BODY}won't work here – May 02 '17 at 17:53\fboxcommand. I.e. it is not possible to display code depending on an if-statement? – Syd Amerikaner May 02 '17 at 17:58\ifstatement, since\BODYis a macro too! – May 02 '17 at 18:00\BODY. – May 02 '17 at 18:26commentpackage and toggle whether themysolutionenvironment is commented out. – Ethan Bolker May 02 '17 at 18:57\verbcommand inside of\textbf{}block? – Werner May 04 '17 at 15:14