Sunteți pe pagina 1din 4

8/2/2018 floats - Border or frame around figure - TeX - LaTeX Stack Exchange

Border or frame around figure

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):

How to add border for an image?

{floats} {framed}

edited Apr 13 '17 at 12:35 asked Aug 22 '11 at 11:13


Community ♦ aioobe
1 1,216 2 11 16

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

1 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

4 Answers

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}

answered Aug 22 '11 at 11:18


Seamus
43.7k 35 209 328

2 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

2 Hmmmm... When I try this (now, 2.5 years after you answered), I get a partial frame (around only the right and
https://tex.stackexchange.com/questions/26269/border-or-frame-around-figure?rq=1 1/4
8/2/2018 floats - Border or frame around figure - TeX - LaTeX Stack Exchange
y ( , y y ), g p ( y g
bottom) and not a complete frame. – Shay Apr 13 '14 at 19:54

Same here, @Shay – 3244611user Dec 11 '16 at 17:31

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

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

construct. See manual pages 181-183.

answered Aug 22 '11 at 14:11


Sardathrion
321 2 13

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}

https://tex.stackexchange.com/questions/26269/border-or-frame-around-figure?rq=1 2/4
8/2/2018 floats - Border or frame around figure - TeX - LaTeX Stack Exchange

answered Oct 23 '11 at 15:56


Mico
259k 30 347 723

tcolorbox is another alternative for boxing any kind of contents, even equations.

Following code shows two example, both produce floating objects, the first shows the box
around the equation but with an independent caption and the second includes the caption as
a title for the box.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}

\newtcolorbox[blend into=figures]{myfigure}[2][]{float=htb,
title={#2},#1}

\begin{document}
\begin{figure}
\begin{tcolorbox}
\[ \sin^2x+\cos^2x=1\]

\[ 1 + \frac{1}{\tan^2x}=\frac{1}{\sin^2x}\]
\end{tcolorbox}
\caption{Some title for these equations}
\end{figure}

\begin{myfigure}{Some title for these equations}


\[ \sin^2x+\cos^2x=1\]

\[ 1 + \frac{1}{\tan^2x}=\frac{1}{\sin^2x}\]
\end{myfigure}

\end{document}

https://tex.stackexchange.com/questions/26269/border-or-frame-around-figure?rq=1 3/4
8/2/2018 floats - Border or frame around figure - TeX - LaTeX Stack Exchange

answered Aug 26 '17 at 17:26


Ignasi
85.2k 4 152 284

https://tex.stackexchange.com/questions/26269/border-or-frame-around-figure?rq=1 4/4

S-ar putea să vă placă și