2

I am using \pst@divide to divide a length in half

\setlength{\RLEN}{4cm}
\addlength{\RLEN}{\OFFSET}
\pst@divide{\RLEN}{2cm}\RLEN
...
\setlength{\DIST}{2cm}
\addlength{\DIST}{\RLEN} % does not work. 

the problem is that \pst@divide returns a float and I need it to be a length because later I add another length to the result using \addlength. Any suggestion how to covert from a float to a length or maybe how to add two float values.

  • "does not work" does not work for me. Please post the actual error message. Normally you simply need to add a unit (pt) if non is included. – Martin Scharrer Jun 14 '12 at 19:30
  • "does not work" means that it has the value 0 – Inquirer Jun 14 '12 at 19:38
  • That's the problem with "does not work". It can man 1.000 different things. – Martin Scharrer Jun 14 '12 at 19:40
  • Sorry, I shall keep that in mind next time :) – Inquirer Jun 14 '12 at 19:41
4

use the etex extension \dimexpr:

\documentclass{article}
\newlength\RLEN
\newlength\DIST
\newlength\OFFSET \OFFSET=1cm
\begin{document}

\setlength\RLEN{\dimexpr4cm+\OFFSET\relax}
\setlength\RLEN{0.5\RLEN}
\the\RLEN

\setlength\DIST{\dimexpr2cm+\RLEN\relax}
\the\DIST

\end{document}

However, you can always use \addtolength\DIST{\XX pt} if \XX is not a length

  • Thanks! That's a much more simpler way for me to do these distance calculations :) – Inquirer Jun 14 '12 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.