[Tex/LaTex] Adding border around figure and caption

captionsfloatsframed

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.

Best Answer

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}