PGF/TikZ Manual | PGFplots | TikZ Editor

TikZ and PGF Manual

The Basic Layer

110 Declaring and Using Images

This section describes the commands for creating images.

110.1 Overview

To be quite frank, ’s \includegraphics is designed better than pgf’s image mechanism. For this reason, I recommend that you use the standard image inclusion mechanism of your format. Thus, users are encouraged to use \includegraphics to include images.

However, there are reasons why you might need to use the image inclusion facilities of pgf:

  • There is no standard image inclusion mechanism in your format. For example, plain does not have one, so pgf’s inclusion mechanism is “better than nothing”.

    However, this applies only to the pdftex backend. For all other backends, pgf currently maps its commands back to the graphicx package. Thus, in plain , this does not really help. It might be a good idea to fix this in the future such that pgf becomes independent of , thereby providing a uniform image abstraction for all formats.

  • You wish to use masking. This is a feature that is only supported by pgf, though I hope that someone will implement this also for the graphics package in in the future.

Whatever your choice, you can still use the usual image inclusion facilities of the graphics package.

The general approach taken by pgf to including an image is the following: First, \pgfdeclareimage declares the image. This must be done prior to the first use of the image. Once you have declared an image, you can insert it into the text using \pgfuseimage. The advantage of this two-phase approach is that, at least for pdf, the image data will only be included once in the file. This can drastically reduce the file size if you use an image repeatedly, for example in an overlay. However, there is also a command called \pgfimage that declares and then immediately uses the image.

To speedup the compilation, you may wish to use the following class option:

  • \usepackage[draft]{pgf}

  • In draft mode boxes showing the image name replace the images. It is checked whether the image files exist, but they are not read. If either height or width is not given, 1cm is used instead.

110.2 Declaring an Image
110.3 Using an Image
110.4 Masking an Image