I have defined my own environment - lets call it 'myenv' - which shows and hides its content based on some global settings. I'm using the \comment
and \endcomment
commands from the verbatim
package, which work really well for me.
However, i've encountered a strange behaviour when enclosing my environment with a box like this (i reduced myenv to this minimal example):
\documentclass[10pt,a4paper]{article}
\usepackage{verbatim}
%define my environment
\newenvironment{myenv}{%
Start:
\comment
}{%
\endcomment
:End
}
\begin{document}
%\parbox{5cm}{ % <- this is where it gets strange
\begin{myenv}
Content
\end{myenv}
%} % <- this is where it gets strange
\end{document}
When i enable the parbox
-lines, i get a list of errors which i don't really understand:
Argument of \verbatim@ has an extra }. }
Paragraph ended before \verbatim@ was complete. }
Extra }, or forgotten \endgroup. }
You can't use `\end' in internal vertical mode. \end{document}
Missing } inserted. \end{document}
Emergency stop.
Something seems to break with the begin
and end
-points...
This also happens with other boxes:
For the \mbox
the error-list is a bit different:
Argument of \verbatim@ has an extra }. }
Paragraph ended before \verbatim@ was complete. }
Extra }, or forgotten \endgroup. }
Emergency stop.
The \fbox
has another error-signature yet again:
Argument of \verbatim@ has an extra }. }
Paragraph ended before \verbatim@ was complete. }
Extra }, or forgotten \endgroup. }
Extra }, or forgotten \endgroup. }
Emergency stop.
The TeX-Primitives \hbox
and \vbox
work fine, as does the minipage
-environment.
So my question is: What is going wrong here and how to resolve this?
verbatim
approaches avoid that, but as David points out, have their own limitations.minipage
works because it is an environment and\parbox
doesn't because it gets the content as a regular argument. What about\hbox
and\vbox
however?