1

I added figures to my latex file and for some reason, it shows them on the right side instead of in the center. How can I fix it?

\begin{figure}
\centering
\subcaptionbox{A Constant Rectangle\label{fig:2a}}[.4\linewidth]{\includegraphics[width=1.6in]{rectangle_graph.png}}
\hspace{1em}
\vspace{0.3em}
\subcaptionbox{A Moving Square\label{fig:2b}}[.4\linewidth]{\includegraphics[width=1.6in]{moving_block_graph.png}}
\vspace{0.3em}
\subcaptionbox{Green Lines\label{fig:2c}}[.4\linewidth]{\includegraphics[width=1.6in]{green_lines_graph.png}}\hspace{1em}
\subcaptionbox{Diagonals\label{fig:2d}}[.4\linewidth]{\includegraphics[width=1.6in]{diagonals_graph.png}}
\caption{caption.}
\label{figure2}
\end{figure}

enter image description here

  • Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}. -- Does Figure alignment using sub caption help? – Bobyandbob Aug 19 '18 at 7:46
  • Do you want to maybe use \begin{figure*} and \end{figure*}? Note the asterisk. – Johannes_B Aug 19 '18 at 7:55
  • If I add * it spreads on both columns. – Shani Gamrian Aug 19 '18 at 8:01
  • What I can see from your picture is that the images have a white border on their left, which can be cured by trimming them (see the trim option); moreover, 1.6in is probably larger than 0.4\linewidth. You can test whether my guess on the white border is right by trying \fbox{\includegraphics{rectangle_graph.png}} and seeing what TeX thinks about the image. – egreg Aug 19 '18 at 9:18
1

do not use absolute values for the width of the images! 3.2in for two images is wider than the column width!

\begin{figure}
\centering
\subcaptionbox{A Constant Rectangle\label{fig:2a}}[.45\linewidth]{%
    \includegraphics[width=\linewidth]{rectangle_graph.png}}
\quad
\subcaptionbox{A Moving Square\label{fig:2b}}[.45\linewidth]{%
    \includegraphics[width=\linewidth]{moving_block_graph.png}}

\subcaptionbox{Green Lines\label{fig:2c}}[.45\linewidth]{%
    \includegraphics[width=\linewidth]{green_lines_graph.png}}
\quad
\subcaptionbox{Diagonals\label{fig:2d}}[.45\linewidth]{%
    \includegraphics[width=\linewidth]{diagonals_graph.png}}

\caption{caption.}
\label{figure2}
\end{figure}

enter image description here

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.