2

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?

  • 2
    Welcome to TeX.SX! Using center inside figure is not good practice, because it adds unwanted space. Better using \centering instead of the center environment. It's not relevant for your problem, though. – egreg Nov 22 '18 at 12:16
3

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}
| improve this answer | |
  • 2
    @Rastapopoulos sorry fixed the missing { :-) – David Carlisle Nov 22 '18 at 12:26

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.