[pstricks] How do you do if then?

Herbert Voss Herbert.Voss at FU-Berlin.DE
Sat Mar 7 07:43:22 CET 2009


David Arnold schrieb:

> This produces a 2 by 4 arrow of boxes. I'd like the first row to have  
> four boxes, but the second row to stop at three boxes. This shoud use  
> some sort of if then statement, I would imagine, to limit the second  
> row to three boxes. How do you use if then in pstricks to get what I  
> want?


\documentclass{article}

\usepackage{pstricks-add}

\def\Box{\psframebox{\rule{3mm}{0pt}\rule{0pt}{3mm}}}
\def\putBox(#1,#2){\rput(#1,#2){\rnode{p#1#2}{\Box}}}

\begin{document}

\begin{pspicture}(1,0.5)(4,2.5)
\multido{\iRow=1+1}{2}{%
  \multido{\iCol=1+1}{4}{%
    \ifnum\iRow=1        % for lowest row
      \ifnum\iCol=4      % and last column do nothing
        \else\putBox(\iCol,\iRow)\fi
    \else\putBox(\iCol,\iRow)\fi}}
\ncbox[linearc=0.35,nodesep=0.2,linecolor=blue]{p11}{p31}
\ncbox[linearc=0.35,nodesep=0.2,linecolor=blue]{p12}{p32}
\end{pspicture}

\end{document}

Herbert



More information about the PSTricks mailing list