2

I have the following file, in which I use the preview package and the beamer class

\documentclass[]{beamer}
\usepackage{preview}
\PreviewEnvironment{align*}
\PreviewEnvironment*{frame}
\begin{document}
\begin{frame}
  Some text and 
  \begin{align*}
    x &= y\\
    \beta &= \gamma
  \end{align*}
  a displayed equation.
\end{frame}
\end{document}

If I ask for generation of previews inside XEmacs all is well,

enter image description here

but when it comes to generating the PDF...

$ pdflatex beamer+previev.tex 
This is pdfTeX, Version 3.14159265-2.6-1.40.15 ...
LaTeX2e <2014/05/01> ...
Document Class: beamer 2013/12/02 3.33 ...
(./beamer+previev.aux) ...
(/usr/local/share/texmf/tex/latex/preview/preview.sty) ...
...
! Undefined control sequence.
\@EveryShipout@Output ...EveryShipout@Org@Shipout 
                                                  \box \@cclv 
l.16 \end{frame}


Overfull \vbox (200.87663pt too high) has occurred while \output is active
! Undefined control sequence.
\@EveryShipout@Output ...EveryShipout@Org@Shipout 
                                                  \box \@cclv 
l.17 \end{document}


Overfull \vbox (200.87663pt too high) has occurred while \output is active
! Undefined control sequence.
\@EveryShipout@Output ...EveryShipout@Org@Shipout 
                                                  \box \@cclv 
l.17 \end{document}

! Undefined control sequence.
\@EveryShipout@Output ...EveryShipout@Org@Shipout 
                                                  \box \@cclv 
l.17 \end{document}


Overfull \vbox (200.87663pt too high) has occurred while \output is active

LaTeX Font Warning: Size substitutions with differences
(Font)              up to 1.0pt have occurred.

 )
(see the transcript file for additional information)
...
$ 

By the way, if I remove the lines

\usepackage{preview}
\PreviewEnvironment{align*}
\PreviewEnvironment*{frame}

I can compile the PDF without any problem, but when I ask for the generation of the inline preview in the XEmacs buffer I get only the warning

 LaTeX found no preview images

in the minibuffer and no image is inserted.

Is there any incantation that I can use to reconcile beamer and preview ways of life?

As a matter of fact, I've just installed preview.sty and all the stuff auctex related this morning, the version is auctex-11.88, while beamer is a bit oldish, but I experienced the same misbehaviour with 11.87 while two (or three?) years ago everything was fine, so this can be a regression I don't know on which side of the barricade...

gboffi
  • 911
  • The whole preview bundle hasn't been essentially touched in the last 8 years or so. – giordano Mar 13 '15 at 11:54
  • In addition, why do you want to load preview? Do you use it just to produce preview snipetts in AUCTeX? It's useless in that case to load the package. – giordano Mar 13 '15 at 12:00
  • @giordano I need to load preview if I want a preview in the editor, I need to load not preview if I want to produce the slides... Anyway I found a solution in a thread I started on the auctex mailing list and was revived like 7 months later, when I was no more following the list! I'm going to write an answer to myself – gboffi Mar 13 '15 at 13:47
  • I repeat, you don't need to load the package for the preview to work in AUCTeX. It's never needed at all (AUCTeX creates an auxiliary file which automatically loads the package). If it's not the case for you, there is a problem. – giordano Mar 13 '15 at 13:56

1 Answers1

2

While I was trying to answer a comment by giordano I thought that I had made similar remarks in a thread that I started in the AUCTeX mailing list almost exactly one years ago, so I searched that old thread to cite some parts of it and, surprise! I noticed that the thread was revived in November, 7 months later, by Nicolas Richard that advanced an hypotesis on the reason of the problem and later diagnosed the exact patch to pgf that caused the problem, finding also another patch that fixed it...

Loyal to SX mantra that links are not good answer, I'll report here the link content (the correct patch is due to Esseger)

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

What else? I applied the patch to pgfutil-latex.def and, at least for my example, everything is OK...

gboffi
  • 911