1

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?

1 Answer 1

2

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.

2
  • Is it possible no to use \expandcoordaux but merge it into a single \expandcoord? Jul 12, 2012 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, 2012 at 9:46

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.