Centering a figure with multiple subfigures
2,995
- similar questions was already asked many, many times ...
- your code snippet is not complete
- newer provide only code snippet, but complete small document called minimal working example (mwe), which begin with
\documentclass{...}
and end with\end{document}
, has in preamble loaded only to your problem relevant packages and exhibits your problem.- show result of your mwe in question, not in link (after time this link can become dead)
your code is rather strange (see leandriis comment above). after removing all superfluous code and arrange your image as you show on image in link, i obtain:
where red lines show page layout and your images are replaced by example images from graphicx
package.
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{figure}[htb]
\begin{subfigure}[b]{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Figure 1.1}
\end{subfigure}%
\hfill%
\begin{subfigure}[b]{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-B}
\caption{Figure 1.2}
\end{subfigure}
\begin{subfigure}[b]{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Figure 1.3}
\end{subfigure}%
\hfill%
\begin{subfigure}[b]{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-B}
\caption{Figure 1.4}
\end{subfigure}
\begin{subfigure}[b]{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{Figure 1.5}
\end{subfigure}%
\hfill%
\begin{subfigure}[b]{0.45\linewidth}
\includegraphics[width=\linewidth]{example-image-B}
\caption{Figure 1.6}
\end{subfigure}
\caption{Figure 1 \dots}
\label{fig:fig 1}
\end{figure}
\end{document}
in your document replace example-image-...
with actual ones and remove all stuff of showframe
.
Related videos on Youtube
Author by
Bradley Jordan
Updated on September 18, 2020Comments
-
Bradley Jordan about 3 years
I'm trying to center graphs in a 2x3 grid. As can be seen from the image output the code places the graph slightly to the right of the page. Ideally I want the vertical gap between graphs to be in the center of the page. I think there is something obvious wrong with my code but i'm not sure what! Any thoughts?
\begin{figure}[H] \centering \begin{subfigure}[b]{0.3\textwidth} \includegraphics[width=2\textwidth]{/Bond/Brazil} \caption{Figure 1.1} \end{subfigure} \qquad \qquad \qquad \qquad \qquad \quad \begin{subfigure}[b]{0.3\textwidth} \includegraphics[width=2\textwidth]{/Bond/Brazil} \caption{Figure 1.2} \end{subfigure} \begin{subfigure}[b]{0.3\textwidth} \includegraphics[width=2\textwidth]{/Bond/Chile} \caption{Figure 1.3} \end{subfigure} \qquad \qquad \qquad \qquad \qquad \quad \begin{subfigure}[b]{0.3\textwidth} \includegraphics[width=2\textwidth]{/Bond/China} \caption{Figure 1.4} \end{subfigure} \begin{subfigure}[b]{0.3\textwidth} \includegraphics[width=2\textwidth]{/Bond/Colombia} \caption{Figure 1.5} \end{subfigure} \qquad \qquad \qquad \qquad \qquad \quad \begin{subfigure}[b]{0.3\textwidth} \includegraphics[width=2\textwidth]{/Bond/Czech_Republic} \caption{Figure 1.6} \end{subfigure}
-
leandriis over 5 yearsReplace
[width=2\textwidth]
by[width=\textwidth]
and your images will not flow into the right margin any more. However, there will be a quite huge white space in the middle. So you might also want to remove the\qquad
s and use a more suitable width for your subfigures.
-
-
Bradley Jordan over 5 yearsThansk so much, appreciate the help. Works perfectly.
-
Zarko over 5 years@BradleyJordan, you are welcome! you also can accept answer by clicking on the check mark on the top left side of answer :-)
-
Bradley Jordan over 5 yearsDone, in future i'll ask questions properly now that I understand how the forum works. Newbie to this, but seems a great community!
-
ado sar almost 2 years@Zarko Why % is needed after
\hfill
? -
Zarko almost 2 years@adosar, it disable empty space after
\hfill
. If distance between images is sufficient large, than this is not (so) important, but when is close to empty space between word, this space can disturbsubfigure
distribution in the figure.