Menu

#316 preview produce to much pages when pgf is loaded.

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

The following document

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

produce 2 pages when compiled with pdflatex in a current texlive 2014. Page 2 contains the text "Text". With texlive 2012 there is no problem: One gets the expected one page document with the "HELLO".

(I suspect that this behaviour is at least in part also responsible for the problem of tikz with auto-pst-pdf: http://tex.stackexchange.com/questions/166623/tikz-and-auto-pst-pdf-break-ghostscript)

Ulrike Fischer

Discussion

  • Herbert Voss

    Herbert Voss - 2014-07-29

    This also depends to the wrong patch of preview.

     
  • Esseger

    Esseger - 2014-09-20

    As in the previous bug (315), this is due to the wrong patch of preview. The hack in pfgutil-latex.def, to make preview compatible with everyshi, is:

    % 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%
    }{}%
    }

    There are two problems with this patch:
    - it does not work if preview is loaded but not active (see bug 315)
    - it does not set \shipout correctly. Indeed, preview has to cancel the shipout of usual pages, so it sets \shipout to a fancy version of "do nothing". But everyshi sets again \shipout to something non-trivial, so usual pages are again output, giving rise to too many pages. So, the patch should again empty \shipout.

    Here is a correct patch:

    \AtBeginDocument{
    \@ifpackageloaded{preview}{%
    % Ok, package loaded. Swap definitions of everyshi.sty's shipout
    % and preview.sty's shipout:
    \ifPreview
    \let\shipout\@EveryShipout@Org@Shipout%This is the null version of \shipout, created by preview and saved by everyshi
    \let\@EveryShipout@Org@Shipout\pr@shipout% This is the original shipout
    \let\pr@shipout\@EveryShipout@Shipout%
    \fi
    }{}%
    }

     
  • Kirill Müller

    Kirill Müller - 2015-03-29

    Is there a workaround which I could apply as a user? Inserting the correct patch above (with \makeatletter and \makeatother) in a document did not work for me.

     
  • Kirill Müller

    Kirill Müller - 2015-03-29

    Save \shipout before \begin{document}, and restore it afterwards.

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

    Reference: http://tex.stackexchange.com/a/235750/8057

     
  • Christian Feuersänger

     
  • Christian Feuersänger

    I have applied the suggested fix as mentioned in the recent comments. It appears to work as expected

     
  • Christian Feuersänger

    • status: open --> closed-fixed