Menu

#315 patch for preview.sty fault

v1.0 (example)
closed-fixed
nobody
None
5
2015-11-28
2014-05-26
U_Fischer
No

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

Discussion

  • Herbert Voss

    Herbert Voss - 2014-07-29

    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.

     
  • Esseger

    Esseger - 2014-09-18

    See the next bug report for a patch solving the loading issue and the spurious pages issue.

     

    Last edit: Esseger 2014-09-20
  • Christian Feuersänger

    I have applied the suggested solution of bug #316 which addresses this here as well.

     
  • Christian Feuersänger

    • status: open --> closed-fixed
     
  • Flow

    Flow - 2015-08-13

    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.

     
  • Christian Feuersänger

    Release 3.0.1 contains this fix.