5

I have an image in PDF format, which I want to show in a much larger format than what fits on the page. For the overflowing parts of the image, I just want it to disappear over the edge.

I tried \includegraphics[width=2\textwidth]{myimage}, but instead of just overflowing the way I want it to, it jumps to the next page.

To complicate things further, the image will overflow the top and right edges of the page, but below the image there will be some space where I want text that complies with the page margins of the rest of the document.

Is there any way to tell LaTeX that I don't care what happens with parts of this image that overflow boundaries?

  • 2
    Have a look on Balancing figure that is wider than document's width. For the horizontal margins it is a duplicate question, but the top overflow needs to be handled differently. – Martin Scharrer Aug 30 '11 at 10:27
  • @Martin: I see ... so my vote to close was premature. – lockstep Aug 30 '11 at 10:35
  • @lockstep: I had to read the question twice as well :-) – Martin Scharrer Aug 30 '11 at 10:41
  • I'm sorry that I was unclear. I had quite a hard time putting down in words what my problem was, so I see how it was hard to figure it out :P – Tomas Aschan Aug 30 '11 at 20:31
2

The overlapping in the margin can be done by placing the image in a \makebox[\textwidth] as shown by egreg or in my answer to Center figure that is wider than \textwidth. The overlapping in the top margin requires the adjustment of the official height as well.

You can do everything very easily using my adjustbox package when using the export option which exports its options also to \includegraphics. The following code scales the image to 2\textwidth, sets the official height to 10cm so that everything above 10cm overlaps in the top margin and aligns it to the left side so that it overlaps in the right margin. I assume here that the image is placed on the top of a page, e.g. direct after a page break or using {figure}[t].

\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{lipsum}
\begin{document}

\noindent
\includegraphics[width=2\textwidth,set height=10cm,left=\textwidth]{tiger}
\lipsum
\end{document}

Result

You can also get the same result by manually using \makebox and \raisebox:

\makebox[\textwidth][l]{\raisebox{0pt}[10cm]{\includegraphics[width=2\textwidth]{tiger}}}
  • Using the package I got an error stating that "option 'export' is unknown for package 'adjustbox'", but the manual version works perfectly! =) Since this is going to be used in a package file, this is more than enough. – Tomas Aschan Aug 30 '11 at 20:50
  • @Tomas: You might have an older version which doesn't has the option. This version is very new. – Martin Scharrer Aug 30 '11 at 21:03
5

Include the image in a box as wide as the \textwidth:

\makebox[\textwidth][l]{\includegraphics[width=2\textwidth]{myimage}}

LaTeX doesn't care if the contents of this box overflows the dimension.


Suppose you want to have a picture spanning the whole paper width; then the trick is similar, but we need to move the starting point to the page border:

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}

\lipsum[1]

\noindent\makebox[\textwidth][l]{%
  \hspace{-\dimexpr\oddsidemargin+1in}%
  \includegraphics[width=\paperwidth,height=2cm]{example-image}%
}

\lipsum[2]

\end{document}

If we are in a twoside context, one has to use \evensidemargin on left hand pages. The ifoddpage package can make the choice automatic.

enter image description here

  • Correct, but this is basically a duplicate answer to the above linked question: tex.stackexchange.com/questions/16582/… – Martin Scharrer Aug 30 '11 at 10:36
  • @Martin I don't agree: that is about letting the image overflow both margins. – egreg Aug 30 '11 at 10:43
  • Indeed, sorry, I sometimes take these differences as too trivial ... :-) – Martin Scharrer Aug 30 '11 at 10:52
  • I’ve tried doing the same, using \paperwidth instead of 2\textwidth. Weirdly, that doesn’t work, it left a little space at the outer border (outside of the margin). What did work was when I used 1.1\paperwidth. – Konrad Rudolph Apr 29 '15 at 12:31
  • @KonradRudolph If you want to have an image that spans \paperwidth you need to move the reference point; I'll add the example to my answer, because doing it in comments is difficult to read. – egreg Apr 29 '15 at 12:42
3
\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\begin{document}

\noindent
\rlap{\includegraphics[width=2\textwidth,viewport=0 0 {2\textwidth} 10cm, clip]{tiger}}
\lipsum
\end{document}

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.