2

The following document produces a PDF with two pages, while only one is called for:

\documentclass{article}
\usepackage{pgfcore}
\usepackage[active]{preview}
\begin{document}
  Text
  \begin{preview}HELLO\end{preview}
\end{document}

While this is a known bug (where I also borrowed the MWE, thanks Ulrike), I'd be curious to know if a workaround at the user level exists, especially one that does not involve changing system files (as in this related question).

(A DVI user also wondered: Does tikz 2.1 no longer work with the preview package? The question here is about pdflatex.)

  • Has the bug been reported? The bug you linked to is filed against PGF/TiKZ but, if I understand the problem correctly, the bug is actually in preview? – cfr Mar 29 '15 at 16:40
  • @cfr: Well, preview is fine as long as pgf is not loaded. On the other hand, pgf does not seem to be affected by preview. (Loading pgf seems to involve \AtBeginDocument at some point, so the order of package loading is irrelevant.) – krlmlr Mar 29 '15 at 17:21
  • @cfr: The bug report suggests that this is an issue between preview and everyshi, but after substituting pgfcore with everyshi the error disappears. I guess pgf itself needs to meddle with \shipout. – krlmlr Mar 29 '15 at 18:22
  • It doesn't follow that the bug is in PGF. I'm not saying it isn't - only that the bug report you linked to suggests that it is. If it isn't, you should provide that information in the discussion of that bug. There evidently was a related bug in PGF at one point, but that one seems to have been fixed in 1.0. – cfr Mar 29 '15 at 18:23
6

A user only needs to save the definition of \shipout just before \begin{document}, and restore it afterwards. Surprisingly, this also works when preview is loaded with the delayed option.

\documentclass{scrartcl}
\pagestyle{empty}

\usepackage{pgfcore}
\usepackage[active,tightpage]{preview}

\let\myshipout\shipout
\begin{document}
  \let\shipout\myshipout

  Text
  \begin{preview}HELLO\end{preview}
\end{document}
  • I have some doubts that this can work. Did you check if the page nodes of tikz still works? Beside this: the patch on sourceforge is not from me, I made only the bug report. – Ulrike Fischer Mar 29 '15 at 20:41
  • @UlrikeFischer: Thanks. Simple tikz figures do work, but I haven't checked page nodes. (In the end, there must be a reason why PGF bothers to play with shipout...) What would be a better way for a user-level patch? – krlmlr Mar 29 '15 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.