[Tex/LaTex] Multiplying lengths by a factor

calculationspstricks

I am trying to create a pspicture where some lengths are calculated in dependency of the size of the pspicture and an included graphic but I am getting the following error message

Illegal unit of measure (pt inserted).

when using the \multiply command with one of these length (see minimal example at the end). The previous \multiply command is working and I cannot figure out, why the second \multiply command does not work. I really hope somebody can help me.

\documentclass{standalone}
\usepackage{pstricks}
\usepackage{graphicx}

\begin{document}
\begin{pspicture}(0cm,0cm)(17cm,24cm)
\newdimen{\FotoHeight}
\newdimen{\PictureHeight}
\PictureHeight=24cm
\settoheight{\FotoHeight}{\includegraphics[width=24cm]{picture.ps}}
\multiply\FotoHeight by 0.5 %This is working
\multiply\PictureHeight by 0.5 %This is throwing the error message
\end{pspicture}
\end{document}

Best Answer

No, neither is working.

Leaving out the pspicture which is not relevant, we can reduce the example to

\documentclass{article}

\newdimen{\FotoHeight}
\newdimen{\PictureHeight}

\begin{document}

\setlength{\PictureHeight}{24cm}
\setlength{\FotoHeight}{2cm}

\multiply\FotoHeight by 0.5 
\multiply\PictureHeight by 0.5

\end{document}

which prints

.5 .5

as readily verified. You can't use a non integer factor for \multiply. So both dimensions are set to zero and the “illegal” tokens are printed.

What you should do is

\FotoHeight=0.5\FotoHeight
\PictureHeight=0.5\PictureHeight

By the way, you shouldn't declare \newdimen in the body of pspicture (I'm dubious if you need it at all), but in the document preamble.