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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Dia to generate a vector based diagram. Then, I export it to PDF, because I want to keep the vector format and want to build my complete document to PDF later on.

When I include my diagram it uses a complete page to include that diagram. How do I import a diagram (PDF) into my document? It only has a single image and I want it to only include that image.

% more bla...


I was already thinking of generating ps2pdf, but that would still give me a PDF file with the same problems probably.

share|improve this question
It sounds like one of your issues is you want to crop the PDF to remove the whitespace around it. That is answered in several places on the site, such as here. pdfcop and Briss are 2 good choices. – DJP Oct 22 '11 at 0:17
Note that you don't need a figure environment to use \includegraphics. You only need one if you want the image to float (which you apparently don't if you use [H]) and/or if you want a \caption (which can be included using other means as well). – Martin Scharrer Oct 22 '11 at 8:32
Either tell Dia to generate a cropped PDF without any whitespace (i.e. not a full A4 or letter sized PDF) or use pdfcrop to generate such a PDF from it. – Martin Scharrer Oct 22 '11 at 8:36
@MartinScharrer I haven't found any options in Dia to do that. I found page setup, but it can only create fixed size papers. So that's a shame. – Marnix Oct 22 '11 at 9:30
@MartinScharrer Where can I find to include graphics without float? I have read the caption documentation, but it doesn't seem to tell me how to do that. And: Why not use float with H? It works fine... – Marnix Oct 22 '11 at 9:58
up vote 12 down vote accepted

You have a couple of options with this "problem".

  1. You can use an external approach and trim the whitespace around the image. pdfcrop is capable of doing this and uses the following interface

    pdfcrop [options] <input[.pdf]> [output file]

    where [ ] denotes optional specifications. If your Dia-exported PDF image, (say) image.pdf, consists of entire blank page with only an image (nothing else on the page like a page number or header/footer), then you can type

    pdfcrop image.pdf image.pdf

    which will trim the excess whitespace, leaving only the image in the PDF. Then you can include it as usual without having to specify the width parameter to \includegraphics:

  2. Another (somewhat) external approach would be to use \includegraphics is the only component in a standalone document class using the following format:

    \usepackage{graphicx}% http://ctan.org/pkg/graphicx


    \usepackage{graphicx}% http://ctan.org/pkg/graphicx
    \usepackage[active,graphics,tightpage]{preview}% http://ctan.org/pkg/preview

    This should produce a trimmed version of your image that you can incorporate in your document in the usual way. standalone uses the preview package to aid in this functionality, so you could use preview as well, as in the second example.

    As commented by @MartinScharrer, this might not work as expected if your bounding box is already a full (whitespace included) page.

  3. You can perform the trimming option from within LaTeX using the trim option of \includegraphics. From the graphicx package documentation:

    bb The argument should be four dimensions, separated by spaces. These denote the 'Bounding Box' of the printed region within the file.

    viewport The viewport key takes four arguments, just like bb. However in this case the values are taken relative to the origin specified by the bounding box in the file. So to 'view' the 1in square in the bottom left hand corner of the area specified by the bounding box, use the argument viewport=0 0 72 72.

    trim Similar to viewport, but here the four lengths specify the amount to remove or add to each side. trim= 1 2 3 4 'crops' the picture by 1bp at the left, 2bp at the bottom, 3bp on the right and 4bp at the top.

    However, you'd have to know (or by trial-and-error) what the bounding box of the contained image is in bp measurements.

  4. Use the adjustbox package which provides \clipbox. It works in a similar manner to the trim option of \includegraphics. It also provides an export package option which exports functionality to \includegraphics. Read the package documentation for more information on this.


  • If you export your image from Dia as an EPS and it is already tightly cropped, then epstopdf can convert them to PDF and you're good-to-go. If the bounding box is not tight, you could try using epstool to tighten it.
share|improve this answer
Note that for 2. that standalone (actually the used preview package) doesn't crop white spaces from included images. It simply crops to the TeX bounding box of the image, which makes it useless in this case. Also \pagestyle{empty} is already included for this class (and not even required as long preview is enabled). – Martin Scharrer Oct 22 '11 at 8:31
Option 1 sounds like a great idea. I will try to install this and see if it runs. Strange that there is no such way for creating cropped PDF's from out Dia. Could I also create an EPS and do something with that instead or is that harder? – Marnix Oct 22 '11 at 9:38

Have you tried using the standalone document class instead of, say, the article document class? It'll automatically crop off all whitespace.

share|improve this answer
He is talking about an external PDF which didn't got created by LaTeX, so standalone is no option here. – Martin Scharrer Oct 22 '11 at 8:28

I found out that I can use the tool called eps2pdf. I can let Dia print an EPS file and then let eps2pdf change it to a pdf that has no a4 format. Since this is not the actual question I asked, I will accept the other answer, but this is how I finally did it.

  1. Dia: Export to an eps file
  2. eps2pdf: Export the file to pdf
  3. \includegraphics{mypdf}
share|improve this answer

Your Answer


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.