[comp.text.tex] putting a box around a figure in LaTeX

johnm@AFSC-BMO.AF.MIL (JohnM) (03/07/91)

I am trying to build a software user's manual (what a novel idea!) and
am encountering a problem creating figures with boxes around them containing
\verbatim text. I use the construct:
     \begin{figure}[ht]
     \caption{caption text}
     \framebox{6in}{
       \begin{verbatim}
          %%% verbatim text
        \end{verbatim}
      } %% end of \framebox{}
      \end{figure}
 
works great without the \framebox...with it, however, i get a splatter of
LaTeX errors.
 
I am sure it is possible to do what I want, I'm probably just looking in
the wrong places. If anyone could help, i'd appreciate it.
 
(go ahead, even bruise my ego with replies like: Hey, bub, look on page 32
of the LaTeX book...isn't that what you want? -- just kidding...i just
need the help).
 
john mulhollen
 
as always, i'll summarize replies back to info-tex. (what a nice guy!).
 
 

FLOWERS@MEMSTVX1.BITNET (Harry Flowers) (03/08/91)

> I am trying to build a software user's manual (what a novel idea!) and
> am encountering a problem creating figures with boxes around them containing
> \verbatim text. I use the construct:
>      \begin{figure}[ht]
>      \caption{caption text}
>      \framebox{6in}{
 
(Need  \framebox[6in]{   in my version of LaTeX)
 
>        \begin{verbatim}
>           %%% verbatim text
>         \end{verbatim}
>       } %% end of \framebox{}
>       \end{figure}
>
> works great without the \framebox...with it, however, i get a splatter of
> LaTeX errors.
>
> I am sure it is possible to do what I want, I'm probably just looking in
> the wrong places. If anyone could help, i'd appreciate it.
 
\begin{figure}[ht]
\caption{caption text}
%
% There's got to be a better way to do this, but this hack will work:
%
% Use \raisebox to fool LaTeX into thinking that the box we draw doesn't take
% up any space.  This allows the verbatim text to start in the box, while TeX
% thinks it is after the box; the verbatim environment does not work inside a
% framebox.  You must adjust the number between "depth" and "\baselineskip" to
% the number of verbatim lines manually, though.  Note: If you don't need the
% full verbatim environment, you *can* use \verb command inside a framebox.
%
\raisebox{-1\baselineskip}[0pt][0pt]{% move the box down a line for verbatim
\framebox[6in]{\vrule height0pt width0pt depth2\baselineskip}} % make the box
\begin{verbatim}
%%% Verbatim text in figure.
This is the second line. %%%
\end{verbatim}
\end{figure}
 
> (go ahead, even bruise my ego with replies like: Hey, bub, look on page 32
> of the LaTeX book...isn't that what you want? -- just kidding...i just
> need the help).
 
Well, if someone comes up with a simple solution, I'll look pretty stupid,
too ;-).  Hope this helps.
 
___  ___  _____  ___ ___ Harry Flowers, Tech Support, Memphis State University
|  \/  | / ____\ | | | | 112 Admin Building | Domain: FLOWERS@MSUVX1.MEMST.EDU
| \  / | \____ \ | |_| | Memphis, TN  38152 | Bitnet: FLOWERS@MEMSTVX1
|_|\/|_| \_____/ \_____/ Ph: (901) 678-2663 | TBRnet: 7171::FLOWERS