# How to define a global constant or a global RPN function without \pstheader?

I want to put

\pstVerb
{
true setglobal
globaldict begin
/side 4 def
/potocar {2 copy cos mul 3 1 roll sin mul} bind def
end
false setglobal
}


in the preamble instead of in pspicture to make it global.

\documentclass[12pt]{beamer}

\usepackage{pst-eucl}

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

\pstVerb
{
true setglobal
globaldict begin
/side 4 def
/potocar {2 copy cos mul 3 1 roll sin mul} bind def
end
false setglobal
}

\begin{document}

\begin{frame}
\begin{pspicture}(-0.2,-0.2)(8,5)
\pstGeonode[PosAngle={180,225,-45,0},CurveType=polygon]
(!0 side){A}
(!0 0){B}
(!80 sin 2 exp side mul 40 sin div 70 sin div 0){C}
(!80 sin side mul 30 sin div 20 potocar){D}\pause

\psset{linecolor=red}
\pstLineAB{A}{D}\pause
\pstLineAB{B}{D}\pause

\psset
{
linecolor=magenta,
linewidth=0.5\pslinewidth,
arcsep=\pslinewidth,
arrows=<->,
LabelSep=0.75,
}

\tiny
% A
\pstMarkAngle{B}{A}{D}{$\theta$}\pause
% B
\pstMarkAngle{C}{B}{D}{$20^\circ$}\pause
% D
\pstMarkAngle{B}{D}{C}{$50^\circ$}\pause
\pstMarkAngle{A}{D}{B}{$30^\circ$}
\end{pspicture}

\end{frame}
\end{document}


I asked AlexG about it in a comment, he responded it but it seemed not to work. I got a compilation error saying that "/undefined in side" in either dvips phase or ps2pdf phase. I am not checked which phase produced the error exactly but latex successfully compiled it.

-
Even if you put the definitions into the pspicture environment, they will be globally accessible afterwards. – AlexG Aug 1 '12 at 8:21
No. Then it is local to the physical page (or overlay in beamer). – AlexG Aug 1 '12 at 8:35
We are still on the same physical page (frame). Try putting \pstVerb{(value of /side:) print side ==} on a fresh frame. – AlexG Aug 1 '12 at 8:44
@AlexG: Oh I see. I misunderstood your term "physical pages" that I meant as a PDF page. :-) – kiss my armpit Aug 1 '12 at 8:51
Ok. I should edit my second comment to frame instead of overlay. Since beamer repeats the pspicture environment and hence the definitions inside \pstVerb{...} on every overlay, side and potocar are always redefined (locally on each overlay!) and therefore available. – AlexG Aug 1 '12 at 9:00

The preview package is the culprit. It seems to discard anything outside \PreviewEnvironment (pspicture in the present case) from being put into the Postscript output. I checked the PS output. The definitions of side and potocar didn't make it into it. If you remove the preview related lines everything is ok.