Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
"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
add comment

1 Answer

up vote 4 down vote accepted

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

share|improve this answer
    
Thanks! That's a much more simpler way for me to do these distance calculations :) –  Inquirer Jun 14 '12 at 19:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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