Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 515
well actually Avatar asked Nov 30 '10 18:11

well actually


People also ask

How do I draw a box around a word in LaTeX?

Line boxesThe command \text creates a line box that creates a line box and is used to typeset the argument without breaking lines and is taken as a single character. This makes the argument extend into the margin. For example, the command \text{speaker} treats the seven characters of the word as one.

How do I enclose a textbox in LaTeX?

The \makebox command creates a box to contain the text specified. The width of the box is specified by the optional width argument. The position of the text within the box is determined by the optional position argument. The \mbox command creates a box just wide enough to hold the text created by its argument.

How do you write verbatim in LaTeX?

The verbatim environment is used to display LaTeX commands instead of having them executed. To display a single command in-line, the \verb|| command can be used. To display a whole block, we can use \begin{verbatim} to open the environment and \end{verbatim} to close it.


1 Answers

Easier: use the fancyvrb package.

\begin{Verbatim}[frame=single]
stuff
\end{Verbatim}
like image 124
Steve Tjoa Avatar answered Nov 05 '22 17:11

Steve Tjoa