# Centering figure consisting of subfigures

I currently have a graph that uses subfigures as follows:

\begin{figure}[!htbp]
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure1.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure2.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure3.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure4.eps}
\caption{}
\end{subfigure}%
\FigureCaptionOpt{caption}{captionCopy}
\end{figure}


As you probably noticed, it overflows the text, since each of the images is 0.3\textwidth and there are 4 images. Now, the whole thing is not centered, instead, it is aligned with the left margin and it overflows the right margin. Essentially, I want to shift it to the left, so that it overflows both margins by the same amount, while maintaining the sizes I specified in the command above.

-
 – Claudio Fiandrino Jan 30 at 16:03

You can just the adjustwidth environment from the changepage package

 \begin{adjustwidth}{<left margin offset>}{<right margin offset>}


I've demonstrated in the MWE below:

I loaded the geometry package with showframe=true just for demonstration, and the demo option for the graphicx package because I don't have your images- remove for the actual document.

\documentclass{article}

\usepackage[showframe=true]{geometry}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{changepage}

\begin{document}
\begin{figure}[!htbp]
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure1.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure2.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure3.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure4.eps}
\caption{}
\end{subfigure}%
\caption{My caption}
\end{figure}

\end{document}

-

I've had good success with the subfig package. I use it as follows:

\begin{figure}[htbp]
\centering
\subfloat[][Caption a\label{fig:subfiga}]{\includegraphics[width=FOO]{imagea.eps}}
\subfloat[][Caption b\label{fig:subfigb}]{\includegraphics[width=FOO]{imageb.eps}}
\\
\subfloat[][Caption c\label{fig:subfigc}]{\includegraphics[width=FOO]{imagec.eps}}
\subfloat[][Caption d\label{fig:subfigd}]{\includegraphics[width=FOO]{imaged.eps}}
\caption{Main Caption}
\label{fig:MainLabel}
\end{figure}


Note I use \qquad for separation and \\ for forced line breaks. You can play with how you space and break the images up, but this should give you a good start. Note that each line is centered, so in this case, "image \qquad image" is centered.

Hope this helps!

-

Without any extra package, you can use \makebox to cheat latex:

\makebox[0pt][c]{<content>}


# Code:

\documentclass{article}

\usepackage[showframe=true]{geometry}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
%\usepackage{changepage}

\begin{document}

\begin{figure}[!htbp]
\centering
\makebox[0pt][c]{%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure1.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure2.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure3.eps}
\caption{}
\end{subfigure}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=3.5cm]{figure4.eps}
\caption{}
\end{subfigure}%
}