[comp.text] Framing a figure TeX/LaTeX

chris@mimsy.UUCP (Chris Torek) (07/19/89)

>In article <957@diemen.cc.utas.oz>, ben@tasis.utas.oz.au@munnari.oz
>(Ben Lian) writes:
>>And here's another question: How can I draw a box around a figure? Tried
>>\framebox but it keeps keeling over with a message about not being in outer
>>par mode, or something like that.

In article <810@csv.viccol.edu.au> dougcc@csv.viccol.edu.au (Douglas Miller)
writes:
>I would think you need to put your figure into a box before you frame it.

Framing a figure is a nefariously nasty typesetting task.  (A little
alliteration there. :-) )  The same problem applies to tables.  Both
of these are categories of `insertions' (or what troff calls `floats').
These are normally not typeset until the last possible moment.  If
there is any adjustable vertical glue, TeX wants to be able to use
it to fix up the page height.  The frame cannot be set until TeX
knows exactly how big the figure (or table) will be.

Anyway, putting it in a box is the right approach.  You can make an
`unbreakable' \vbox containing an \hbox that frames the insertion.
The handiest way to do this in LaTeX is to put the figure inside a
`minipage'.  This needs to know how wide to set the figure.  Alas,
\framebox adds about 10pt of spacing.  I faked it out below, but to
do it right requires knowing exactly how much space \framebox adds.

\documentstyle{article}
\newdimen\mpwidth
\begin{document}
\section foo
\begin{figure}
\framebox{%\vbox{
\mpwidth=\textwidth \advance\mpwidth -10pt
\begin{minipage}{\mpwidth}
Here is some stuff to be inserted in a figure.
Now is the time for all good men to come to the aid of their computers.
Now is the time for all good men to come to the aid of their computers.
Now is the time for all good men to come to the aid of their computers.
Now is the time for all good men to come to the aid of their computers.
Now is the time for all good men to come to the aid of their computers.
Now is the time for all good men to come to the aid of their computers.
Now is the time for all good men to come to the aid of their computers.
Now is the time for all good men to come to the aid of their computers.
Now is the time for all good men to come to the aid of their computers.
\end{minipage}
}
%}
\end{figure}
\end{document}
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

leichter@CS.YALE.EDU (Jerry Leichter) (07/21/89)

In article <18629@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes...
>Framing a figure is a nefariously nasty typesetting task.  (A little
>alliteration there. :-) )  The same problem applies to tables.  Both
>of these are categories of `insertions' (or what troff calls `floats').
>These are normally not typeset until the last possible moment.  If
>there is any adjustable vertical glue, TeX wants to be able to use
>it to fix up the page height.  The frame cannot be set until TeX
>knows exactly how big the figure (or table) will be.

The question here is, exactly what do you want the frame to enclose?  If
you want it to enclose the CONTENTS of the figure, with spacing added around
it, you can do that by making the contents an object with a frame around it.
LaTeX inserts shrinkable/expandable glue between figures and a between them
and the main text.

On the other hand, if you want the frame to enclose "the space taken up by
the figure", in general the only solution would be to modify LaTeX to get it
to box up figures as it inserts them.  Fortunately, this is not a common
requirement.

>Anyway, putting it in a box is the right approach.  You can make an
>`unbreakable' \vbox containing an \hbox that frames the insertion.
>The handiest way to do this in LaTeX is to put the figure inside a
>`minipage'.  This needs to know how wide to set the figure.  Alas,
>\framebox adds about 10pt of spacing.  I faked it out below, but to
>do it right requires knowing exactly how much space \framebox adds.
> 
[example omitted]
The spaced added around a framebox is given by \fboxsep, which you can change
within a group surrounding the \framebox.

However, there is a simpler solution:  Get the boxedminipage style file from
the latex-style collection at Clarkson.  A boxedminipage is just like a
minipage, except that it is surrounded by a box, with \fboxsep of space
separating the enclosed text from the box.
							-- Jerry