using the verbatim environment within a question

Added by David Thompson over 9 years ago

I just bumped into "Paragraph ended before \xverbatim@ was complete" when running xelatex on an AMC document. Is there a workaround which facilitates using the verbatim environment within a question? (The beamer allows one to declare a frame 'fragile' -- can something similar be done in AMC?). Thanks for your time and any suggestions/advice.

- Alan


Replies (5)

RE: using the verbatim environment within a question - Added by Alexis Bienvenüe over 9 years ago

As you experienced, the verbatim environment cannot be used inside AMC questions... You can consider including the verbatim material inside a box that will be called in the AMC question. If you have any idea to fix the automultiplechoice.sty file, I am interested!

RE: using the verbatim environment within a question - Added by David Thompson over 9 years ago

Thanks for the quick response! Unfortunately, my latex-fu is pretty minimal. However, I took a closer look at Beamer to see how 'fragile' frames are implemented -- it looks like the strategy used there is to dump the content of a 'fragile' frame into a file and then grab the file contents later (see the beamerbaseframe.sty file).

RE: using the verbatim environment within a question - Added by Pieter Van den Hombergh over 9 years ago

Maybe the package fancyverb can fix your problem.
I used it in another context, but the idea is to use the two macros \SaveVerb{key}:value: and then at the appropriate place \UseVerb{key}.

In particular I use it to print out (one time) passwords to pdf files and these password have tex unfriendly characters in them.
That exemplary use is then.

\SaveVerb{pass}:Somes3cr@t: 

.
.
.
Your password is & \UseVerb{pass} \\

As you can see I use the : (colon) as verbatim boundaries.

RE: using the verbatim environment within a question - Added by Alexis Bienvenüe over 9 years ago

Maybe the package fancyverb can fix your problem.

Interesting!

Another similar idea: perhaps using the \verbatiminput command from the verbatim package (with the content in a separate file) works?

RE: using the verbatim environment within a question - Added by David Thompson over 9 years ago

I'm guessing the fancyverb tools would do the trick but, for my application, \verbatiminput works great. Thanks for the suggestion.

(1-5/5)