2

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
    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
2

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
3

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?

  • 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 '18 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. – Martin Scharrer Apr 8 '18 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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