I'm trying to use \beginpgfgraphicnamed to externalise some complex figures in a large document, using the latest released version of TiKZ (2.00). This produces standalone PDF images but for me the graphic is shifted up: the top part of the image is cut off and the bottom part has unnecessary whitespace. The overall PDF that is generated by pdflatex when these externalised images are used has the same visual problem, so I'm having to drop the idea of externalising graphics for now.

As far as I can tell the overall size of the pictures is correct (when comparing to the version without externalisation). I am using a custom thesis style file that changes margins, which is probably breaking several of the l2tabu no-no's.

How does PGF/TiKZ calculate the positioning of pictures on the page, at least as this affects positioning of externalised pictures?

In particular, are there specific things to tweak or to avoid tweaking to ensure this problem does not happen? I'm trying to not embark on a big LaTeX hacking project like redoing the style based on a more modern documentclass than report, so ways to steer clear of this would be especially welcome.


2 Answers 2


You can set the bounding box of a tikzpicture explicitly by using \useasboundingbox or more TikZ'ish:

\path[use as bounding box] (0,0) rectangle (10,10); % adjust to fit

in your tikzpicture.

You will have to provide some more information if the above is not what you want. As stated above, the way to control the size of a tikzpicture is to set the bounding box manually if you are not happy with what TikZ is calculating. To quote the pgfmanual (section Establishing a bounding Box):

pgf is reasonably good at keeping track of the size of your picture and reserving just the right amount of space for it in the main document. However, in some cases you may want to say things like "do not count this for the picture size" or "the picture is actually a little large." For this you can use the option use as bounding box or the command \useasboundingbox, which is just a shorthand for \path[use as bounding box].

You might also try using the external library


this offers some additional functionality on top of the

\beginpgfgraphicnamed ...\endpgfgraphicnamed.

Alternatively, the preview package offers a way to extract tightly cropped parts of a document

  • 1
    If your external figures were created in LaTeX, then I second the recommendation for using the preview package in those figures. Preview will automatically crop the PDF to the exact size of the LaTeX environment you are using to draw the figure, without having to guess at bounding boxes.
    – ESultanik
    Commented Aug 17, 2010 at 14:00
  • 1
    I spent so long looking for just this thing. Thanks so much!
    – Richard
    Commented Jun 14, 2012 at 17:19

To position a picture on the page you could use the current page node. Here is an example doing it that way, placing a blue square in the top left corner of the page:

\begin{tikzpicture}[remember picture,overlay]
  \node[yshift=-1cm] at (current page.north west) {%
    \begin{tikzpicture}[remember picture, overlay]
      \draw[fill=LightSkyBlue] (0,0) rectangle (1cm,1cm);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .