# Adding border around figure and caption

There is a Word-based submission guideline that shows following formatting for figures:

Note that there is a border around both the Figure and the caption.

Question: What's the most elegant way to add the borders?

I have seen related posts here and here but they seem to address a different problem.

• While the float and floatrow packages can box figures, they leave the caption empty, and even prevent the caption from being boxed. – John Kormylo Apr 6 '18 at 16:11

Here is a version using \fbox. It is easier to put the caption into a separate \fbox than add a line with the desired spacing.

\documentclass{article}
\usepackage{mwe}% or graphicx and blindtext

\begin{document}
\blindtext

\begin{figure}
\lineskip=-\fboxrule
\fbox{\begin{minipage}{\dimexpr \textwidth-2\fboxsep-2\fboxrule}
\centering
\includegraphics{example-image}
\end{minipage}}
\fbox{\begin{minipage}{\dimexpr \textwidth-2\fboxsep-2\fboxrule}
\abovecaptionskip=0pt
\caption{The caption text}
\end{minipage}}
\end{figure}

\blindtext
\end{document}

• Thx! What's the best way to adjust the width of the figue (with frames)? I tried to set it for \includegraphics[width=0.5\textwidth] but the figure is still the full width. – TensorJoe Apr 8 '18 at 18:32
• The figure itself is always \textwidth or \columnwidth. The \fbox size is determined by the size of the minipage (plus 2\fboxsep and 2\fboxrule). You can measure the size of an image using a savebox. – John Kormylo Apr 9 '18 at 1:39

There are multiple ways. One would be to use the adjustbox package to add a frame first to the image, then to both the framed image and the caption. Proper margins can be added using the margin key. I also add a negative margin to draw the second frame on top of the first one.

\documentclass{article}

\usepackage{mwe}
\begin{document}
\blindtext

\begin{figure}
\begin{adjustbox}{varwidth=\textwidth,margin=0 {\abovecaptionskip} 0 0, frame=1pt }
\includegraphics[margin=5mm,center,frame=1pt,margin=-1pt]{example-image}
\bfseries
\caption{The caption text}

To make the caption bold there is most likely a better way, maybe using the caption package?