[Tex/LaTex] Center figure that is wider than \textwidth

floatshorizontal alignmentmargins

I have a figure that is wider than the \textwidth of my document. (I don't want to change the \textwidth.) As a result, the leftmost part of the figure is flush with the left margin, while the rightmost part spills into the right margin too much. I'd like to center the figure, so that it will exceed the \textwidth equally on both sides.

Best Answer

Put the content of your figure environment into a \makebox[\textwidth][c]{...} macro. This will center its content to the normal text width even if it is wider than that. See also my similar answer to Place figures side by side, spill into outer margin.

The image can also be aligned to the left and right using [l] and [r], which makes the image lap into the right or left margin, respectively.

Example:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{figure}
  \makebox[\textwidth][c]{\includegraphics[width=1.2\textwidth]{image}}%
  \caption{Caption}
  \label{fig:key}
\end{figure}
\end{document}

Starting from 2011/08/13 you can also use adjustbox package for such alignments. For centering use the center=<length> which centers the content in the given length. The length is optional and defaults to \linewidth which is normally identical to \textwidth. There is also left and right as well as inner and outer.

\documentclass{article}
\usepackage[export]{adjustbox}[2011/08/13]
\begin{document}

\begin{figure}
  \includegraphics[width=1.2\textwidth,center]{image}%
  \caption{Caption}
  \label{fig:key}
\end{figure}
\end{document}