Consider the following MWE:
Code: Select all
\documentclass{article}
\usepackage{auto-pst-pdf,pstricks-add}
\usepackage[locale=DE]{siunitx}
\definecolor{nicered}{rgb}{0.796,0.255,0.329}
\begin{document}
\begin{figure}
\def\WidthPallet{46}
\def\length{22.8}
\def\height{5.4}
\def\rows{2}
\def\EachRow{8}
\pstFPdiv\faktor{\EachRow}{\rows}
\def\startX{\WidthPallet\space \EachRow\space \height\space mul sub 2 div}
\def\startY{\WidthPallet\space \rows\space \length\space mul sub 2 div}
\centering
\psset{unit=0.25cm}
\begin{pspicture}(\WidthPallet,\WidthPallet)
\pnode(0,0){P1}
\pnode(0,\WidthPallet){P2}
\pnode(\WidthPallet,\WidthPallet){P3}
\pnode(\WidthPallet,0){P4}
\pspolygon[fillstyle=solid,fillcolor=brown](P1)(P2)(P3)(P4)
\multido{\iA=1+1,\iB=0+1}{\EachRow}{%
\psRelNode(!\startX\space \startY\space)(!\startX\space \height\space add \startY\space){\iB}{A\iA}
\psRelNode(!\startX\space \startY\space \length\space add)(!\startX\space \height\space add \startY\space \length\space add){\iB}{B\iA}
\psRelNode(!\startX\space \startY\space 2 \length\space mul add)(!\startX\space \height\space add \startY\space 2 \length\space mul add){\iB}{C\iA}
\psRelNode(!\startX\space \height\space add \startY\space 2 \length\space mul add)(!\startX\space 2 \height\space mul add \startY\space 2 \length\space mul add){\iB}{D\iA}
\psRelNode(!\startX\space \height\space add \startY\space \length\space add)(!\startX\space 2 \height\space mul add \startY\space \length\space add){\iB}{E\iA}
\psRelNode(!\startX\space \height\space add \startY\space)(!\startX\space 2 \height\space mul add \startY\space){\iB}{F\iA}
\pspolygon[fillstyle=solid,fillcolor=nicered](A\iA)(B\iA)(E\iA)(F\iA)
\pspolygon[fillstyle=solid,fillcolor=nicered](B\iA)(C\iA)(D\iA)(E\iA)
}
\psset{nrot=:U,offset=-19pt,linestyle=dashed,fillcolor=nicered}
\pcline[offset=12pt]{<->}(P1)(P4)
\ncput*{\SI{\WidthPallet}{\cm}}
\pcline{<->}(B1)(C1)
\ncput*{\SI{\length}{\cm}}
\pcline{<->}(C1)(D1)
\ncput*{\scriptsize{\SI{\height}{\cm}}}
\end{pspicture}
\end{figure}
\end{document}
\multido
in order to `automatically' draw \rows
rows of \EachRow
rectangles on top of each other? In other words: How do I extend the above code in order to draw \rows
rows on top of each other instead of just 2 rows?Thank you in advance!
P.S. I have looked at this answer but I cannot make it work.
Update
I forgot to post (one of) my initial tries:
Code: Select all
\begin{figure}
\def\WidthPallet{46}
\def\length{22.8}
\def\height{5.4}
\def\rows{2}
\def\EachRow{8}
\pstFPdiv\faktor{\EachRow}{\rows}
\def\startX{\WidthPallet\space \EachRow\space \height\space mul sub 2 div}
\def\startY{\WidthPallet\space \rows\space \length\space mul sub 2 div}
\centering
\psset{unit=0.25cm}
\begin{pspicture}(\WidthPallet,\WidthPallet)
\pspolygon[fillstyle=solid,fillcolor=brown](0,0)(0,\WidthPallet)(\WidthPallet,\WidthPallet)(\WidthPallet,0)
\multido{\iA=1+1,\iB=0+1}{\EachRow}{%
\multido{\iC=1+1}{\rows}{%
\psRelNode(!\startX\space \startY\space)(!\startX\space \height\space add \startY\space \iC \row mul add){\iB}{A\iA}
\psRelNode(!\startX\space \startY\space \length\space \iC \row mul add add)(!\startX\space \height\space add \startY\space \length\space \iC \row mul add add){\iB}{B\iA}
\psRelNode(!\startX\space \height\space add \startY\space \length\space \iC \row mul add add)(!\startX\space 2 \height\space mul add \startY\space \iC \row mul add \length\space add){\iB}{C\iA}
\psRelNode(!\startX\space \height\space add \startY\space \iC \row mul add)(!\startX\space 2 \height\space mul add \startY\space \iC \row mul add){\iB}{D\iA}
\pspolygon[fillstyle=solid,fillcolor=nicered](A\iA)(B\iA)(C\iA)(D\iA)
}
}
\psset{nrot=:U,offset=-19pt,linestyle=dashed,fillcolor=nicered}
\pcline{<->}(A1)(B1)
\ncput*{\SI{\length}{\cm}}
\pcline{<->}(B1)(C1)
\ncput*{\scriptsize{\SI{\height}{\cm}}}
\end{pspicture}
\end{figure}