1

I want to define a constant globally within my pspicture environment as follows:

\begin{pspicture}(4,2)
\psgrid
\SpecialCoor
\def\length{2}
\pnode(!\length 1){C}
\uput[90](C){$C$}
% other codes truncated here for simplicity.
\end{pspicture}

The above example does not work.

What is the correct way to do that?

migrated from stackoverflow.com Jul 27 '11 at 9:07

This question came from our site for professional and enthusiast programmers.

3

We can use a (La)TeX macro or PS verb. When using a (La)TeX macro, \space is needed to prevent the macro from eating things after it. But when using PS verb, \space is not needed.

See the following for the details.

\documentclass{minimal}
\usepackage{pstricks-add}
\def\LENGTH{2}
\begin{document}
  \begin{pspicture}[showgrid=true](4,2)
    \SpecialCoor
    \pstVerb{/length 2 def}
    \pnode(!\LENGTH\space 1){C}
    \pnode(! length 1){D}
    \uput[90](C){$C$}
    \uput[180](D){$D$}
  \end{pspicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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