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 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?

share|improve this question
add comment

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

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

1 Answer

up vote 2 down vote accepted

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}
share|improve this answer
add comment

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.