Take the 2-minute tour ×
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.

I am putting a presentation together using beamer. I have a few tikz/pgf pictures that I externalize. Yet the figures are not put back into the document correctly. They are not in the right spot on the slides and the captions are missing. The externalization did produce the figures correctly as far as I can tell. I have the same problem when using the hyperref package in article class documents. As far as I know beamer uses hyperref in itself?

I am unsure how to circumvent this issue, any ideas?

Here's a simple working example

\documentclass[red]{beamer}
  \usepackage{tikz}
  \usepackage{pgfplots}
  \usepgfplotslibrary{external}
  \tikzexternalize
  \tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"; dvips -o "\image".ps "\image".dvi}}
  \tikzset{external/force remake}
\begin{document}
  \frame{
    \begin{figure}
      \centering
      \tikzsetnextfilename{MyFig}
      \begin{tikzpicture}
        \begin{axis}[xmin=0,xmax=5,
           ymin=1,ymax=6,
                   domain=0:5]
      \addplot [red] {x*x-2*x+3};
        \end{axis}
      \end{tikzpicture}
      \label{fig:MyFig}
      \caption{This text is missing}
    \end{figure}
  }
\end{document}

I compile with, with TeXLive:

latex -interaction=nonstopmode -shell-escape %.tex; dvips -o %.ps %.dvi; ps2pdf %.ps
share|improve this question
    
It works fine for me. Can you post your compile logs? BTW, you should use \begin{frame}...\end{frame} instead of \frame{...} –  Aaron Jun 12 '12 at 4:10
    
Any recommendations where to upload them to? Both the main log and the externalized log are 1000+ lines. Doesn't seem suitable to copy paste them on here... :) –  Markus Jun 12 '12 at 15:53
    
Here the main log and externalized log –  Markus Jun 12 '12 at 16:05
    
This seems to be a driver issue: the generated MyFig.ps has a wrong bounding box. In fact, MyFig.dvi contains two bounding box instructions: the first is wrong, the second is correct... might be something between beamer and tikzexternal. –  Christian Feuersänger Jun 18 '12 at 20:10
add comment

2 Answers

up vote 2 down vote accepted

This is a driver incompatibility between geometry and tikz: geometry issues some \special paper size options before tikz can.

A work-around seems to be to add

\tikzifexternalizing{%
    \geometry{driver=none}
}{}%

to your preamble.

This tells geometry to avoid changing the paper size - but only if an external image is currently being generated.

An alternative is to use a different driver (pdflatex does not seem to be affected).

share|improve this answer
    
I have added support for this detection to PGF CVS, i.e. it will become part of the next version of PGF. –  Christian Feuersänger Jun 18 '12 at 20:40
add comment

A workaround I have found, is to go the pdf2ps route within the externalization. I am quite lost as to why this works...

\documentclass[red]{beamer}
  \usepackage{tikz}
  \usepackage{pgfplots}
  \usepgfplotslibrary{external}
  \tikzexternalize
  %%\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"; dvips -o "\image".ps "\image".dvi}}
  \tikzset{external/system call={pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"; pdf2ps "\image".pdf "\image".ps}}
  \tikzset{external/force remake}
\begin{document}
  \frame{
    \begin{figure}
      \centering
      \tikzsetnextfilename{MyFig}
      \begin{tikzpicture}
        \begin{axis}[xmin=0,xmax=5,
           ymin=1,ymax=6,
           domain=0:5]
           \addplot [red] {x*x-2*x+3};
        \end{axis}
      \end{tikzpicture}
    \label{fig:MyFig}
    \caption{This text is missing}
  \end{figure}
}
\end{document}
share|improve this answer
    
even better: use pdftops -level3 -eps -paper match "\image".pdf "\image".eps instead of pdf2ps to greatly reduce file size. –  Markus Jun 18 '12 at 18:54
add comment

Your Answer

 
discard

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.