I am including figures from a paper I'm writing into the associated presentation slides written in beamer. Both the paper and the slides are pdf and I'm typesetting using pdflatex. I'm using \includegraphics[page=1, trim=1 2 3 4,clip=true]{paper.pdf} to include chunks of the paper.pdf into the beamer presentation. However, I've found that the trim command seems to include the entire page, but renders everything outside the trim'd area transparent. If I drag my mouse cursor over the areas outside the included figure in the presentation slides, I can still see and select the text surrounding the figure which has also been inserted into my slides (it's just invisible).

This has the side effect of making the size of slides.pdf very large because all this extraneous information around the figure is dragged along, but rendered transparent. Is there anyway to not include or remove this extraneous information from my slides.pdf somehow?

  • 1
    It is easy to clip bitmap graphics: You simply remove pixels. But your graphics is a vector image and there is not simple way to remove e.g. a part of a circle path or a bezier curve. That's why pdf "clips" by making the parts transparent. If you need a true clip you will have to convert your graphic to a bitmap. Aug 17 '12 at 8:41
  • Given that it will be projected on a screen (as it's beamer) you can make a reasonable guess as to the largest possible resolution so converting to bitmap is not an unreasonable thing to do. Of course, the resulting bitmap might be bigger than the PDF ... Aug 17 '12 at 9:26
  • Theoretically, that's what you'd expect. In practice, I find that whenever I include a png in my slides, it is visually lower quality (more blurry) than when I include a pdf, even if I have more resolution than I need in the png. I think it has to do with one pixel in the png not corresponding to exactly one pixel on the screen and some interpolation needs to happen.
    – Chah
    Aug 17 '12 at 13:47

Yes, the whole PDF page is always included. Options trim and viewport only select the box that is seen by TeX and option clip only makes the part outside the box invisible. But option clip does not read the PDF image page contents, analyzes its page stream operators and rewrites the page stream for the only inclusion of the visible elements. This is not a trivial task at all. I do not know a freeware tool that is able to do this automatically except for rendering to a bitmap.

Without converting to a bitmap (and loss of quality) it is not easy to remove the invisible parts.

  • Commercial tools?

  • Manually in vector programs that are able to deal with PDF, e.g. inkscape.

With good knowledges of PDF (or PostScript) the removal can also be manually done by editing the PDF or PostScript files directly. But it depends on the familiarity with the formats, the complexity of the PDF file and the elements that should be removed.

The box could cut through characters. It is possible to select the dot of an i. But if you want to remove the stem, you would have to go to the glyph description of the character in the embedded font.

  • Thanks for the answer. It explains why its implemented that way. I've managed to get the source code for the paper. I'll grab most of the figures I need from the source.
    – Chah
    Aug 17 '12 at 9:28

This is one of the (actually not so many) things that are very easy to accomplish on a Mac and very difficult on all other systems.

On Mac OSX, PDF is the native format of the clipboard. As a result, PDF viewers that are build on Apples PDFKit (basically all, but Acrobat) provide the feature to copy a rectangular selection for a PDF page and paste it into a new document (as vector graphics!).

For my beamer presentations, I usually use the built-in Preview application to copy & paste figures from the various PDF sources and collate them together as pages into a single figures.pdf PDF file. I then use \includegraphics[page=xx,...]{figures.pdf} to include the respective figure.

The resulting PDF files stored by Preview do not contain the complete content of the respective source files. They are, however, generally not very optimized with respect to size. If size does matter, I employ either Acrobat or ghostscript (as described in this answer) to generate a size-optimized version.

This works very well in practice. For me, the flexible PDF handling is the major reason to stick with OS X.


I usually tackle this issue by running gs over the pdf files using the following options:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default \
   -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages \
   -sOutputFile=in.pdf out.pdf

This usually works.


It is not possible inside TeX but you can crop it in advance using other external tools.

  • Hmm.. I kind of don't want to have all these extra files lying around. But if there's no other option, which external tool do you recommend to maintain the highest quality and lowest file size?
    – Chah
    Aug 17 '12 at 8:40
  • @Chah: ImageMagick. Aug 17 '12 at 9:04

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.