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 forgot the rule to use \expandafter such that \rect can be used as the point arguments of both psframe and pspicture.

\documentclass{standalone}

\usepackage{pstricks}

\def\rect{(-3,-3)(3,3)}

\begin{document}

\begin{pspicture}[showgrid=top]\rect
    \psframe[linecolor=red]\rect
\end{pspicture}

\end{document}

Could you review it once more?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

PSTricks expects

\begin{pspicture}[<options>]

to be followed by explicit coordinates. Thus \rect must be expanded before TeX starts looking to \begin.

\newcommand{\expandcoord}[2]{%
  \expandafter\expandcoordaux\expandafter{#2}{#1}%
}
\newcommand\expandcoordaux[2]{#2#1}

Then you can say

\expandcoord{\begin{pspicture}[showgrid=top]}{\rect}
  \expandcoord{\psframe[linecolor=red]}{\rect}
\end{pspicture}

The main problem here is that \expandafter only jumps over one token, so an indirect way has to be taken. This, of course, will break auto-pst-pdf or similar packages.

share|improve this answer
    
Is it possible no to use \expandcoordaux but merge it into a single \expandcoord? –  Who is crazy first Jul 12 '12 at 9:33
    
@HiggsBoson No. There is no primitive method for jumping over a braced group, so in a way or the other auxiliary macros must be employed. It wouldn't be too difficult to extend PSTricks so that \begin{pspicture}[<options>] accepts to be followed by "implicit coordinates"; however, doing it for all PSTricks commands such as \psframe would require extensive work. –  egreg Jul 12 '12 at 9:46

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.