4

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

Figure

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.

1
  • 1
    While the float and floatrow packages can box figures, they leave the caption empty, and even prevent the caption from being boxed. Apr 6, 2018 at 16:11

2 Answers 2

5

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}
2
  • 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, 2018 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. Apr 9, 2018 at 1:39
8

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[export]{adjustbox}
\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}
   \end{adjustbox}
\end{figure}

\blindtext
\end{document}

enter image description here

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

2
  • I tried, bur for some reason, I can't get two things: 1) Thinner lines that don't overlap 2) centering the caption. I tried a \centering almost everywhere. Any idea?
    – TensorJoe
    Apr 8, 2018 at 18:34
  • 1) Change ALL 1pt values in my example to the value you want. The margin must fit the frame thickness. 2) In my case the caption is centered. Without knowing more about your used preample I can't say why this is not the case for you. Apr 8, 2018 at 19:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .