Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to place a border / frame around my figure.

The figure is a bunch of equations:

\begin{figure}[ht]
    \[ eqn 1 \]

    \[ eqn 2 \]

    \[ eqn 3 \]

    \caption{\label{myfig} My caption.}
\end{figure}

I've tried putting an \fbox{...} and \framebox[\textwidth]{...} around the equations but it doesn't work.

Preferably, I'd like the border to not include the caption.

Any hints are welcome...


Related question (though it concerns \includegraphics instead):

share|improve this question
    
it seems there's no [figure] tag. any reason why? if not, could someone with 300+ perhaps "invent it" by adding it to this question? –  aioobe Aug 22 '11 at 11:13
    
There's a floats tag which is for questions about figure and table environments, which are very similar. I added it to your question. figures is an alias tag which maps to floats. –  Stefan Kottwitz Aug 22 '11 at 13:24
    
I see. Thanks :-) –  aioobe Aug 22 '11 at 13:26
add comment

3 Answers

up vote 7 down vote accepted

With the package mdframed or framed this is possible

\documentclass{article}
\usepackage{mdframed}
\begin{document}
\begin{figure}[ht]
\begin{mdframed}
    \[ eqn 1 \]

    \[ eqn 2 \]

    \[ eqn 3 \]
\end{mdframed}
    \caption{\label{myfig} My caption.}
\end{figure}
\end{document}
share|improve this answer
1  
Thanks, what's the difference between framed and mdframed? –  aioobe Aug 22 '11 at 11:20
    
@aioobe mdframed has more options and has, in my opinion, a more user friendly interface for customising it. (mdframed frames can also break nicely across pages, but since you're using it in a float, this doesn't matter) –  Seamus Aug 22 '11 at 11:21
    
Hmmmm... When I try this (now, 2.5 years after you answered), I get a partial frame (around only the right and bottom) and not a complete frame. –  Shay Apr 13 at 19:54
add comment

Using memoir (a package for books), you can use the

\begin{framed}
[...]
\end{framed} 

construct. See manual pages 181-183.

share|improve this answer
add comment

IF you don't want to use the memoir documentclass, as is suggested in @Sardathrion's answer, you could use the float package and, in particular, its \floatstyle{boxed} and \restylefloat commands.

A nice feature of the float package is that it provides the H location specifier, as in "I really want this float HERE and nowhere else". Two idiosyncracies of the "boxed" float style are (i) the width of the boxes is that of \textwidth (plus a small fudge factor, so that an object of full \textwidth width fill fit) and (ii) captions of table and figure floats will always be placed below the respective objects. (To change this behavior, one will have to delve into the innards of the code of the float package.)

Aside: if you set tables with the "boxed" float style, you'll definitely want to use as few \hline commands as possible (or, even better, none at all).

\documentclass{article}
\usepackage{float,lipsum}
\floatstyle{boxed}
\restylefloat{table}
\restylefloat{figure}
\begin{document}
\lipsum[1]
\begin{figure}[H]
\centering
ABCDEFG
\caption{A very simple figure}
\end{figure}

\bigskip
\begin{table}[h]
\caption{An equally simple table}
\begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}rlrlr@{}}
Here & There & Here & There & Here & There 
\end{tabular*}
\end{table}

\lipsum[2]
\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.