Consider the following example.
Code
% pdflatex -shell-escape test.tex
\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 }
\edef\faktor{\the\numexpr\EachRow/\rows\relax\space}
%\edef\startX{\the\numexpr(\WidthPallet-\EachRow*\height)/2\relax\space}
\def\startX{\WidthPallet \EachRow \height mul sub 2 div}
%\edef\startX{\the\numexpr(\WidthPallet-\rows*\length)/2\relax\space}
\def\startY{\WidthPallet \rows \length mul sub 2 div}
\centering
\psset{
unit=0.26cm
}
\begin{pspicture}(\WidthPallet,\WidthPallet)
\psframe[
fillstyle=solid,
fillcolor=brown
](0,0)(\WidthPallet,\WidthPallet)
\psset{
fillstyle=solid,
fillcolor=nicered,
dimen=middle
}
\rput(!\startX\space \startY\space){%
\multido{\rA=0+\height}{\EachRow}{%
\multido{\rB=0.0+\length}{\rows}{%
\psframe(\rA,\rB)(!\rA\space \height add \length \rB\space add)
}
}
}
\psset{
linestyle=dashed,
fillcolor=nicered,
arrows=<->,
nrot=:U,
offset=-19pt
}
\pcline(!\startX\space 0.6 \WidthPallet mul)(!\startX\space \height add 0.6 \WidthPallet mul)
\ncput*{\scriptsize\SI{\height}{\cm}}
\pcline(!\startX\space \startY\space)(!\startX\space \length \startY\space add)
\ncput*{\SI{\length}{\cm}}
\pcline(!0 0.65 \WidthPallet mul)(!\WidthPallet 0.65 \WidthPallet mul)
\ncput*{\SI{\WidthPallet}{\cm}}
\end{pspicture}
\end{figure}
\end{document}
Output
Question
Why can't I replace
\def\startX{\WidthPallet \EachRow \height mul sub 2 div}
\def\startY{\WidthPallet \rows \length mul sub 2 div}
by
\edef\startX{\the\numexpr(\WidthPallet-\EachRow*\height)/2\relax\space}
\edef\startX{\the\numexpr(\WidthPallet-\rows*\length)/2\relax\space}
in order to get rid of some of the \space
s?