Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a project to draw something that is more complicated than the following. Apparently I cannot use w after invoking \psaxes with [$x$,0][$y$,90]. I found it after struggling for 1 hour.

enter image description here

\documentclass{standalone}
\usepackage{pstricks-add}

\begin{document}
\begin{pspicture}(-4,-4)(4,4)
    \pstVerb{/w 1 def}%
    \psaxes{->}(0,0)(-2,-2)(2,2)%
    [$x$,0][$y$,90]%<=== source of problem!
  \psline{-*}(!w w)
\end{pspicture}
\end{document}

Can you see the strange output? The radius of the point should be the square root of 2 cm.

How do I know that w must not be used if there is no warning/error message?

Edit: Another example where a single letter identifier produces a weird output!

\documentclass[pstricks,border=0pt]{standalone}
\usepackage{pstricks-add}

\begin{document}
\multido{\i=0+30}{12}{%
\begin{pspicture}(4,4)
    \pstVerb{/a 1 def}
    \uput{5mm}[0](2,2){$\i^\circ$}
\end{pspicture}}
\end{document}
share|improve this question

2 Answers 2

up vote 15 down vote accepted

it is not a good idea to define global variables with only one letter. They are also used inside the PostScript part. Use at least uppercase letters or better two characters:

\documentclass{standalone}
\usepackage{pst-plot}

\begin{document}
\pstVerb{/ww 1 def}
\begin{pspicture}(-4,-4)(4,4)
  \psaxes{->}(0,0)(-2,-2)(2,2)[$x$,0][$y$,90]
  \psline{-*}(!ww ww)
\end{pspicture}
\end{document}
share|improve this answer
    
Just curious, why didn't you use @ as the prefix? –  stalking is prohibited Jul 10 '12 at 17:49
    
I am talking about PostScript where @ is nothing special. The problem is \pstVerb it defines everything global so that a @ wouldn't help anyway –  Herbert Jul 10 '12 at 17:50

A recommended solution is to use userdict begin ... end construct. It is more flexible than the accepted answer.

\documentclass{standalone}
\usepackage{pstricks-add}

\begin{document}
\begin{pspicture}(-4,-4)(4,4)
    \pstVerb{userdict begin /w 1 def end}%
    \psaxes{->}(0,0)(-2,-2)(2,2)%
    [$x$,0][$y$,90]%<=== source of problem!
  \psline{-*}(!userdict begin w w end)
\end{pspicture}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.