I would like to show and hide a verbatim or spverbatim environment based on a boolean condition (sth. like \showenv). I tried the solutions proposed at Hide custom environment content based on boolean, e.g. when using



Test 1
  Test 2

I get the following errors:

! Undefined control sequence.
\env@myenv@process -> \ifshow
! Extra \else.
! Extra \fi.
! Paragraph ended before \@tempa was complete.
! Paragraph ended before \verbatim@test was complete.
  • You can't use \NewEnviron for processing verbatim material. There are already similar questions on the site. – egreg Sep 1 '14 at 16:49
  • I tried some proposed solutions but they either don't work (e.g. the first one from tex.stackexchange.com/questions/69009) or I get the same or similar errors (the second one). – problemzebra Sep 2 '14 at 8:18

I think the comment-environment of the verbatim package is what you are searching for. Here is an example how to define myenv according to your requirements.






Test 1
% some verbatim text

Test 2
% some verbatim text
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.