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?
\if
statement yet. And you environment ends withsolution
, not withmysolution
;-)\fbox{\BODY}
won't work here\fbox
command. I.e. it is not possible to display code depending on an if-statement?\if
statement, since\BODY
is a macro too!