pgf hacks preview in pgfutil-latex.def to make it compatible with
everyshi and makes there a faulty assumption:
% Preview hack: preview.sty hacks into \shipout (which is ok), but
% does not honour everyshi.sty (which is not ok). This causes
% everyshi material to get lost.
\AtBeginDocument{
\@ifpackageloaded{preview}{%
% Ok, package loaded. Swap definitions of everyshi.sty's shipout
% and preview.sty's shipout:
\let\pgf@temp\pr@shipout% This is the original shipout
\let\pr@shipout\@EveryShipout@Shipout%
\let\@EveryShipout@Org@Shipout\pgf@temp%
}{}%
}
This code assumes that \pr@shipout is defined if preview is loaded,
but actually \pr@shipout is only defined if preview is active.
Imho the code should be changed to
\AtBeginDocument{
\@ifpackageloaded{preview}{%
% Ok, package loaded. Swap definitions of everyshi.sty's shipout
% and preview.sty's shipout:
\ifPreview
\let\pgf@temp\pr@shipout% This is the original shipout
\let\pr@shipout\@EveryShipout@Shipout%
\let\@EveryShipout@Org@Shipout\pgf@temp%
\fi
}{}%
}
Due to the faulty patch documents like this fails:
\documentclass{article}
\usepackage{pgfcore}
\usepackage{preview}
\begin{document}
Text
\begin{preview}HELLO\end{preview}
\end{document}
with
! Undefined control sequence.
\@EveryShipout@Output ...EveryShipout@Org@Shipout
\box \@cclv
Ulrike Fischer
There is also a problem if preview is used together with package
auto-pst-pdf. Then I need the original definition of preview. Otherwise I'll get two pages in the PS-output instead of one. The patch should be:\AtBeginDocument{
\@ifpackageloaded{auto-pst-pdf}{}{%
\@ifpackageloaded{preview}{%
% Ok, package loaded. Swap definitions of everyshi.sty's shipout
% and preview.sty's shipout:
\ifPreview
\let\pgf@temp\pr@shipout% This is the original shipout
\let\pr@shipout\@EveryShipout@Shipout% This is what preview.sty should call
\let\@EveryShipout@Org@Shipout\pgf@temp% Everyshi should now use the original one
\fi
}{}%
}%
}
However, it is not a good idea to patch it via \AtBeginDocument, which can only be overwritten by a user with another one. An optional argument like PatchPreview=true/false would make sense.
See the next bug report for a patch solving the loading issue and the spurious pages issue.
Last edit: Esseger 2014-09-20
I have applied the suggested solution of bug #316 which addresses this here as well.
Any ETA for a new release including the fix? I'm asking because of https://bugs.gentoo.org/show_bug.cgi?id=536622, which is blocking a few other bugs.
Release 3.0.1 contains this fix.