为什么 beamer+pstricks+preview 现在不再兼容?

为什么 beamer+pstricks+preview 现在不再兼容?

在此处输入图片描述

以下代码取自 Gonzalo Medina'在这里回答(点击)。当他发布答案时,代码是可编译的。

\documentclass{beamer}
\usepackage{pstricks-add}
\usepackage[active,tightpage]{preview}
\PreviewBorder=0pt
\PreviewEnvironment{pspicture}

\begin{document}

\begin{frame}
    \begin{pspicture}(6,6)
        \pnode(0,0){A}
        \pnode(6,0){B}
        \pnode(6,6){C}
        \pnode(0,6){D}
        \pnode(1,1){P}
        \pnode(5,1){Q}
        \pnode(3,5){R}
        \only<5>{\psclip{\pscircle[linestyle=none,dimen=middle](3,3){3}}}
        \only<1->{\pspolygon*[linecolor=red](A)(B)(Q)(P)}
        \only<2->{\pspolygon*[linecolor=green](B)(C)(R)(Q)}
        \only<3->{\pspolygon*[linecolor=blue](C)(D)(R)}
        \only<4->{\pspolygon*[linecolor=yellow](D)(A)(P)(R)}
       \only<5>{\endpsclip}
     \end{pspicture}
\end{frame}

\end{document}

在此处输入图片描述

但是现在,相同的代码不再能编译并出现错误/typecheck in --div--

实际上,我想编译下面的代码,但也会出现同样的错误。哪里出了问题?

\documentclass{beamer}
\usepackage{pstricks}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{pspicture}
\PreviewBorder=12pt\relax


\begin{document}

\begin{frame}{Test}
\psset{unit=.5cm,runit=.5cm}
\begin{pspicture}[showgrid=top](-7.5,-7.5)(7.5,7.5)
\pstVerb
{   
    %true setglobal
    %globaldict begin
    /c40 {40 cos} bind def
    /s40 {40 sin} bind def
    /s65 {6 5 s40 mul add} bind def
    %end
    %false setglobal
}
\pscircle[linecolor=blue]{8}
\pscustom[fillstyle=solid,fillcolor=black!20]{%
  \only<1->{\psarc(0,0){5}{40}{! 180 0.3 ATAN1 sub }}
  \only<2->{\psline(! 37.5 c40 mul s65 div 1.5)(! 32.5 c40 mul s65 div 0.5)}
  \only<3->{\psarc(0,0){5}{!180 0.1 ATAN1 sub}{!180 0.1 ATAN1 add}}
  \only<4->{\psline(! 27.5 c40 mul s65 div -0.5)(! 22.5 c40 mul s65 div -1.5)}
  \only<5->{\psarc(0,0){5}{!180 0.3 ATAN1 add}{320}}
  \only<6->{\psarcn(0,0){6}{! 270 5 c40 mul 36 25 c40 dup mul mul sub sqrt div ATAN1 add }{! 270 0.25 Acos sub }}
  \only<7->{\psline(-7.5,-1.5)(!5 c40 mul s65 div 7.5 sub -0.5)}
  \only<8->{\psarcn(0,0){6}{!180 1 12 atan add}{!180 1 12 atan sub}}
  \only<9->{\psline(-7.5,0.5)(! 5 c40 mul s65 div 7.5 sub 1.5)}
  \only<10->{\psarcn(0,0){6}{!180 1.5 6 atan sub}{! 1 c40 div 10 div 36 25 10 sin mul sub 60 s40 mul add mul s65 div ATAN1}}
  \only<11->{\closepath}
}
\end{pspicture}
\end{frame}
\end{document}

法医痕迹记录

最后一次成功编译代码是在2012年7月29日,最后一次更新preview是在2010年。因此preview可以从导致该问题的候选列表中删除。 pstricks和还beamer剩下,但哪一个是问题的根源?

答案1

问题出在 pgf(文件 pgfutil-latex)中,预览的 shipout 重新定义导致创建的 dvi/ps 文件出现问题。它总是创建两个页面而不是一个。但是,这里有一个解决方法:

\listfiles
\documentclass{minimal}
\usepackage{auto-pst-pdf}
\makeatletter
\let\Test@pr@shipout\pr@shipout%% save the original definition
\let\Test@shipout\shipout
\makeatother
\usepackage{tikz}
\makeatletter
\AtBeginDocument{%
  \let\pr@shipout\Test@pr@shipout%% restore it 
  \let\shipout\Test@shipout
}
\makeatother
\usepackage{pstricks}

\begin{document}
X
\begin{pspicture}[showgrid=false](6,6)
\psline(6,6)
\rput*(3,3){foo}
\end{pspicture}
X
\end{document}

也可以看看https://sourceforge.net/p/pgf/bugs/315/

答案2

根据我对我的回答问题,下面的代码可以实现你想要的功能(至少 texlive2013 在 5 月份左右进行了最新更新)

\documentclass[beamer,pstricks]{standalone}
\usepackage{etex}

\def\myxmin{-7.5}%
\def\myymin{-7.5}%
\def\myxmax{7.5}%
\def\myymax{7.5}%

\newlength{\pspicwidth}
\newlength{\pspicheight}
\newlength{\border}
\setlength{\border}{12pt}%


\psset{unit=.5cm,runit=.5cm}
\setlength{\pspicwidth}{\dimexpr \myxmax\psxunit -\myxmin\psxunit + 2\border\relax}
\setlength{\pspicheight}{\dimexpr \myymax\psxunit -\myymin\psxunit +2\border\relax}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Set the frame size to the pspicture size %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\geometry{%
  paperheight=\pspicheight,%
  paperwidth=\pspicwidth,
  left=0cm,right=0cm,%
  bottom=0cm,top=0cm}


\begin{document}
\begin{standaloneframe}
  \hspace{\border}%
  \vspace{-\border}%
  \begin{pspicture}[showgrid=top](\myxmin,\myymin)(\myxmax,\myymax)
    \pstVerb
        {   
          %true setglobal
          %globaldict begin
          /c40 {40 cos} bind def
          /s40 {40 sin} bind def
          /s65 {6 5 s40 mul add} bind def
          %end
          %false setglobal
        }
        \pscircle[linecolor=blue]{8}
        \pscustom[fillstyle=solid,fillcolor=black!20]{%
          \only<1->{\psarc(0,0){5}{40}{! 180 0.3 ATAN1 sub }}
          \only<2->{\psline(! 37.5 c40 mul s65 div 1.5)(! 32.5 c40 mul s65 div 0.5)}
          \only<3->{\psarc(0,0){5}{!180 0.1 ATAN1 sub}{!180 0.1 ATAN1 add}}
          \only<4->{\psline(! 27.5 c40 mul s65 div -0.5)(! 22.5 c40 mul s65 div -1.5)}
          \only<5->{\psarc(0,0){5}{!180 0.3 ATAN1 add}{320}}
          \only<6->{\psarcn(0,0){6}{! 270 5 c40 mul 36 25 c40 dup mul mul sub sqrt div ATAN1 add }{! 270 0.25 Acos sub }}
          \only<7->{\psline(-7.5,-1.5)(!5 c40 mul s65 div 7.5 sub -0.5)}
          \only<8->{\psarcn(0,0){6}{!180 1 12 atan add}{!180 1 12 atan sub}}
          \only<9->{\psline(-7.5,0.5)(! 5 c40 mul s65 div 7.5 sub 1.5)}
          \only<10->{\psarcn(0,0){6}{!180 1.5 6 atan sub}{! 1 c40 div 10 div 36 25 10 sin mul sub 60 s40 mul add mul s65 div ATAN1}}
          \only<11->{\closepath}
        }
  \end{pspicture}
\end{standaloneframe}
\end{document}

在此处输入图片描述

相关内容