Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a multipage pdf document and would like to include only the upper part (say 3cm down and 2cm right from upper left corner) of a given page. Including part of a single page can be done with \includegraphics,

\documentclass[twoside,a4paper,12pt]{report}

\usepackage{graphicx}

\begin{document}
\includegraphics*[page=7,width=\textwidth,viewport=30 30 120 120]{file.pdf}

\end{document}

but how do change the units to something like cm or inches?

share|improve this question
    
Nobody keeps you from putting the unit cm after the numbers. –  user9588 Jan 7 '12 at 16:31
    
use it, e.g.: viewport=1cm 1cm 4cm 5cm –  Herbert Jan 7 '12 at 16:37
    
that simple, who would have thought... –  D.Roepo Jan 7 '12 at 17:08

1 Answer 1

up vote 3 down vote accepted

I'd measure the graphics (original size) and then trim it. I assume that you want to enlarge that zone to the text width

\begin{figure}
\centering
\sbox{0}{\includegraphics{filename}}
\setlength{\dimen6}{\wd0}\setlength{\dimen8}{\ht0}
\includegraphics[%
  width=\textwidth,
  trim=0 {\dimexpr\dimen8-3cm\relax} {\dimexpr\dimen6-2cm\relax} 0,
  clip]{filename}
\caption{Particular of the upper left corner of the page}
\end{figure}

The four parameters for trim= are the amount to be trimmed on the left, below, on the right and above respectively. With clip you are telling pdftex to not show the trimmed part.

Note that this doesn't require measuring manually the graphics. However, you find the bounding box information in the log file.

The scratch registers used are \dimen6 and \dimen8 that are not used by graphicx.sty; one must, however, check that the result is what's expected. The safest way would be to define two lengths for the purpose.

share|improve this answer
    
What are the \dimenX's in {\dimexpr\dimenX-Ycm\relax} if I now also want to clip off the top and the left? Where can i find documentation on this? –  D.Roepo Oct 15 '13 at 9:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.