Discussion:
\fbox around a figure
(too old to reply)
Herve Saint-Amand
2003-07-16 19:45:37 UTC
Permalink
Hello,

I'm using LaTeX to write a book. There's a part of the book that
requires some mathematical knowledge. I'd like to have a framed box
that takes a whole page and contains the related math explanations. It
would have a figure's characteristics (a caption, a label so that I
can reference it), and would have a solid border to outline it and
make it clear that it's a digression from the main text.

I tried the following, but I seem to understand from the error
messages that you can't put a figure in an fbox.

=======================================
\fbox{
\begin{figure}
\input{mathexplanations}
\caption{Math explanations}
\label{mathexpl}
\end{figure}
}
=======================================

Any suggestions (code or readings) ?

thanks a lot
Herb
Stefan Ulrich
2003-07-16 23:19:59 UTC
Permalink
Post by Herve Saint-Amand
I'd like to have a framed box
that takes a whole page and contains the related math explanations.
[...]
Post by Herve Saint-Amand
I tried the following, but I seem to understand from the error
messages that you can't put a figure in an fbox.
Yes, because a figure is a floating object. You can put the
fbox around a minipage *inside* the figure:


\documentclass{article}
\usepackage{calc}% for width calculations
\begin{document}
\begin{figure}
\fbox{%
\begin{minipage}{\textwidth-2\fboxsep-2\fboxrule}
explanations
\caption{Math explanations}
\end{minipage}%
}%
\end{figure}
\end{document}
--
Stefan Ulrich
Peter Wilson
2003-07-16 23:42:24 UTC
Permalink
Post by Herve Saint-Amand
Hello,
I'm using LaTeX to write a book. There's a part of the book that
requires some mathematical knowledge. I'd like to have a framed box
that takes a whole page and contains the related math explanations. It
would have a figure's characteristics (a caption, a label so that I
can reference it), and would have a solid border to outline it and
make it clear that it's a digression from the main text.
I tried the following, but I seem to understand from the error
messages that you can't put a figure in an fbox.
=======================================
\fbox{
\begin{figure}
\input{mathexplanations}
\caption{Math explanations}
\label{mathexpl}
\end{figure}
}
=======================================
The figure environment is a float --- it will "float" away from any box.
Try putting the box inside the figure environment but around the
illustration and caption.

Peter W.
Will Henney
2003-07-17 04:58:33 UTC
Permalink
Post by Herve Saint-Amand
I'm using LaTeX to write a book. There's a part of the book that
requires some mathematical knowledge. I'd like to have a framed box
that takes a whole page and contains the related math explanations. It
would have a figure's characteristics (a caption, a label so that I
can reference it), and would have a solid border to outline it and
make it clear that it's a digression from the main text.
I tried the following, but I seem to understand from the error
messages that you can't put a figure in an fbox.
=======================================
\fbox{
\begin{figure}
\input{mathexplanations}
\caption{Math explanations}
\label{mathexpl}
\end{figure}
}
=======================================
Any suggestions (code or readings) ?
I'm sure there's a million packages that will do this
sort of thing but it's pretty easy to roll your own. Your
problem is that \fbox requires its contents to be `simple'.
The solution is to hide the complexity inside a \parbox so
that \fbox just sees the `outside' of the box. You still
couldn't have \fbox outside \begin{figure}, but there is
no need for that. Here is an example:

\documentclass{article}
\usepackage{calc}

\setlength\fboxsep{20pt}
\setlength\fboxrule{2pt}

\newlength\InnerWidth
\setlength\InnerWidth{\textwidth - 2\fboxsep - 2\fboxrule}

\newcommand\B{Blah, blah, blah.\ }
\newcommand\BB{\B\B\B\B\B\B\B\B\B\B}
\newcommand\BBB{\BB\BB\BB\BB}

\begin{document}
\BBB\BBB\BBB
\begin{figure}[t!]
\fbox{\parbox{\InnerWidth}{
\BBB
\caption{Math explanations}
\label{mathexpl}
}}
\end{figure}
\BBB\BBB\BBB
\begin{figure}[t!]
\fbox{\parbox{\InnerWidth}{
\BBB\BBB
\caption{More math explanations}
\label{moremathexpl}
}}
\end{figure}
\BBB\BBB\BBB
\BBB\BBB\BBB

\end{document}
Herve Saint-Amand
2003-07-17 15:18:23 UTC
Permalink
Outstanding! Thank you all for your answers, I will give them all a try!

cheers
Herb

Loading...