Latex: how to draw box around text that contains a verbatim block
Asked Answered
G

1

21

Typically, to box in some text, I use the following:

\fbox {
    \parbox{\linewidth}{
    This is some text! Blah blah blah...
    }
}

However, say I have a verbatim block within that. It will never compile. Anyone know how I could draw a box around text which contains a verbatim block? Like this for example...

\fbox {
    \parbox{\linewidth}{
        \begin{verbatim}
        This is some text!
        \end{verbatim}
    }
}

I should not that I re-posted this in tex.stackexchange after CPF pointed out that there was such a thing. Let me know if people are opposed to doubled posting. If not, I'll keep it up here as well.

Galvin answered 30/11, 2010 at 18:56 Comment(3)
Sounds like this should go to tex.stackexchange.com , shouldn't it?Adulterer
Yeah, I suppose it should. Didn't know there was such a thing. Thanks..Galvin
It was moved to there.Gibbons
C
35

Easier: use the fancyvrb package.

\begin{Verbatim}[frame=single]
stuff
\end{Verbatim}
Courtroom answered 30/11, 2010 at 19:7 Comment(2)
Note that Verbatim is case sensitive and this will not work with verbatim. (Just to help anyone else that got caught by same problem as me)Untwine
The above comment is right, but to rephrase it: you really do need Verbatim with the upper case V. The normal verbatim will not work with that option.Unclinch

© 2022 - 2024 — McMap. All rights reserved.