# Quickest way to include graphics

Whenever I make a presentation with LaTeX, it takes me a long time to include the graphics in the way I want them to look.

• I start with \includegraphics{foo.jpg},
• run pdflatex to see what it looks like,
• then add [trim=1cm 2cm 3cm 4cm],
• run pdflatex to see what it looks like,
• then add [scale=.8],
• then run pdflatex,
• then change [trim=...],
• then change [scale].... etc.

Is there a tool that lets on manipulate the picture directly and then produces the LaTeX source? Or what is a better practice to achieve the results?

-

## 4 Answers

A good practice IMHO is, depending on the type of graphic:

• Photos: Use the JPG format and crop it to the size and viewport your need using an image processing program, e.g. Gimp or Photoshop. DO NOT use JPG for anything else, it is really just thought for photos. It can handle other stuff as well but not as good as other formats.

• Screenshoots and other Artificial Pixel-graphics: Use PNG format and again crop it to the size and viewport needed. The PNG format is lossless, i.e. doesn't create artifacts like JPG. Its compresses this kind of images well.

• Diagrams, Pictures and other Vector-graphics: Should really be included as vector-graphics and not as pixel-graphics (and if so NOT as JPG!). You should export them as PDF or EPS which is then converted to PDF (e.g. epstopdf). Extra whitespace from margins etc. can be removed by pdfcrop.

To include your image:

• the width (and height) option should IMHO be preferred before scale in many cases, e.g. larger graphics. A width=x\textwidth (x = 0.95 .. 0.8) normally includes larger images nicely. The scale options is better suited to increase smaller images or adjust middle sized images when they already have almost the correct size.
• In beamer presentation I had to watch the height as well. Note that in beamer the \textheight spans over the frame title, so height=\textheight will not result in a good slide.

About your current method:

• If you are using trim to remove white space (see also above), you might want to also use the clip option to get fully rid of it. (Ok, with white space it doesn't make much difference)
• There are tools which give you a live preview, like the -pvc mode of latexmk. Use it for the recompilation while you change the settings.
• Note that beamer has a \includeonlyframe which allows you to only compile certain frame, which speeds things up during adjustments and creation of e.g. TikZ pictures.
-
Thank you, this has helped me a lot. –  Hans Feb 14 '11 at 8:18

use package overpic for an overlay grid. Then it is easy to find the correct values for trim:

\documentclass{article}
\usepackage[abs]{overpic}
\begin{document}

\begin{overpic}[scale=.25,grid,tics=10]{tiger}
\end{overpic}

\end{document}


I run this example with latex->dvips->ps2pdf, because there is only a tiger.eps. Use any other jpg, png or pdf graphic, if you want to run pdflatex.

-
Thank you! I didn't know about overpic. –  Hans Feb 14 '11 at 8:19

I would create the graphic at the size I want in the paper (for example, by using a graphics editing program) and then use \includegraphics{foo} with no other modifications needed.

-
But be careful to use the correct DPI value (72, 300?) for it, otherwise it will be in a different size once in the PDF. –  Martin Scharrer Feb 13 '11 at 10:38
@Martin: As I understand, the image doesn't need to have the "correct" resolution, as long as it has the information about its resolution in its metadata. If it doesn't, LaTeX will assume a default resolution (which is what happened in this question). –  Jake Feb 13 '11 at 10:48
@Jake: This is what I meant. –  Martin Scharrer Feb 13 '11 at 10:51

Regarding the "fine-tuning" bit of your question (of how to best integrate pictures into your document) you may also find using an editor like gummi useful, which offers live previews while editing.

-