[Tex/LaTex] Define a “square” command


I try to define the following command, for drawing a square in pstricks:

\newcommand{\square}[4] {

I use it like this (for drawing a red square with a corner at (1,1) and a side-length of 3):


And get the following errors:

Package xcolor error: Undefined color '1'.
Missing number, treated as zero.
Illegal unit of measure (pt inserted).

What am I doing wrong?

(Additionally, if there is a simpler way to write this square command, I will be happy to learn..)

Best Answer

Use the PSTricks object definition. Then you have the same syntax for options and star versions:


\def\square{\pst@object{square}}% reads star and options and continues with \square@i




enter image description here

Related Question