Documente Academic
Documente Profesional
Documente Cultură
\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.
{floats} {framed}
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
\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}
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
\begin{framed}
[...]
\end{framed}
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
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}
\[ 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
https://tex.stackexchange.com/questions/26269/border-or-frame-around-figure?rq=1 4/4