5

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}
2
  • Welcome to TeX.SX! I get no error from the code (after adding \usepackage{graphicx}, of course). Anyway, neither operation works in the way you wish to.
    – egreg
    Mar 28, 2017 at 15:50
  • I added the \usepackage{graphicx} to the example.
    – Vanessa
    Mar 29, 2017 at 8:35

2 Answers 2

7

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.

1
  • Thank you for the solution. You are right, I do not actually need \newdimen, I used now \newlength and worked with \setlength{FotoHeight}{0.5\FotoHeight}. I did not stumble over any additional problems with this.
    – Vanessa
    Mar 29, 2017 at 8:33
0
\documentclass{standalone}
\usepackage{pstricks}
\usepackage{graphicx}
\newsavebox\PBox
\newlength\FotoHeight 
\newlength\PictureHeight 

\begin{document}
\sbox\PBox{\includegraphics[width=24cm]{picture.ps}}

\setlength\FotoHeight{0.5\ht\PBox}
\setlength\PictureHeight{24cm}
\setlength\PictureHeight{0.5\PictureHeight}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .