[Tex/LaTex] \fbox around multiple \includegraphics

boxesfloats

I am working on a figure like this,

\begin{figure}
      \includegraphics[width=\textwidth]{a.png}
      \includegraphics[width=\textwidth]{b.png}
      \includegraphics[width=\textwidth]{c.png}
\end{figure}

and would like to draw a box around the figures.
I tried

\begin{figure}
      \fbox{%
          \includegraphics[width=\textwidth]{a.png}
          \includegraphics[width=\textwidth]{b.png}
          \includegraphics[width=\textwidth]{c.png}
      }
\end{figure}

but then all the figures appear on one line (and, therefore, out of the page).
Is there a simple fix to this?

Best Answer

You are only adding a space and then relying on line breaking to put the figures on separate lines, and there is no line breaking in an fbox, you could do

 \fbox{\parbox{.8\textwidth}{% or whatever you need
         \centering
          \includegraphics[width=\linewidth]{a.png}

          \includegraphics[width=\linewidth]{b.png}

          \includegraphics[width=\linewidth]{c.png}
      }}

You need the \fbox to be a bit narrower that \textwidth to leave room for the border. If you want it to fit exactly use

\parbox{\dimexpr\textwidth - 2\fboxsep - 2\fboxrule}
Related Question