I'm trying to recreate a figure and caption effect from a journal. An example of it can be seen on PDF version of Figure 1 from this article:
It's basically a large grey bordered box that goes around the image and caption, and the bottom section, where the caption is filled in grey.
I'm currently using
\usepackage{xcolor}
\usepackage{mdframed}
\mdfdefinestyle{mystyle1}{
backgroundcolor=white!20
}
\mdfdefinestyle{mystyle2}{
backgroundcolor=lightgray!20
}
in the preamble, and
\begin{figure}[htb!]
\centering
\begin{mdframed}[style=mystyle1]
\includegraphics[width=1.0\textwidth]{foo.pdf}
\begin{mdframed}[style=mystyle2]
\caption[foo]{foo}
\end{mdframed}
\end{mdframed}
\label{fig:foo}
\end{figure}
This creates a box around the whole figure and caption, and then a subbox around the caption, but they don't lineup, and I can't figure out how to change the border colour.
Any help would be appreciated.
Best Answer
Below I present one option using
tcolorbox
to define afigurebox
environment. This environment has an optional argument to specify placement options (just as for the standard figure environment).Instead of using two boxes, I just used one box; the upper part is used for the image and the lower one, for the caption. Use
\tcblower
just before\caption
.The
caption
package was used to easily change the color for the caption labels. Change the settings according to your needs:The output: