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've got some macros storing information about various dimensions. When I start dividing by dimensions, though, I'm getting answers that don't make sense.

\documentclass{article}
\usepackage[landscape]{geometry}
\makeatletter
\def\aetopmargin{0.85in}%%
\def\aebotmargin{0.5in}%%
\def\aeworkspacetopsep{4ex}
\def\aeworkspacerulesep{0.65cm}
\edef\aeworkspaceheight{\dimexpr\paperheight-\aeworkspacetopsep-\aetopmargin-\aebotmargin}
\typeout{==>Work space height===>\strip@pt\dimexpr\aeworkspaceheight}
\typeout{==>Work space rule: ===>\strip@pt\dimexpr\aeworkspacerulesep}
\typeout{==>Their quotient is===>\strip@pt\dimexpr \dimexpr\aeworkspaceheight\relax / \dimexpr\aeworkspacerulesep\relax \relax}
\makeatother
\pagestyle{empty}
\begin{document}
empty
\end{document}

When I run this I get the following output on the terminal:

==>Work space height===>499.5079
==>Work space rule: ===>18.49411
==>Their quotient is===>0.00041

Shouldn't I be getting something more like

==>Their quotient is===>27.00902...
share|improve this question
    
Nevermind now I got what you mean. Sorry –  percusse Apr 10 at 20:28
    
rather than defining a macro, try using \newdimen\xxx \setdimen\xxx0.85in etc. –  barbara beeton Apr 10 at 20:29
    
@barbarabeeton I could do that, but it's actually easier for the current document if I don't have to work with dimensions for these values. On the surface, I'm sure that sounds absurd. But I designed the document around the macros because for the most part I'm actually not using these as dimensions. –  A.Ellett Apr 10 at 20:32
    
pgfmath reports the correct values so it must be an ambiguous interpretation of etex –  percusse Apr 10 at 20:34
1  
It needs parenthesis around them to your previous comment :) –  percusse Apr 10 at 20:41
show 5 more comments

1 Answer 1

up vote 7 down vote accepted

You can only divide by a length number , returning a length using etex / you can not divide two lengths to get a number. So if you divide by a length it is cast to a number by taking the length as an integer number of sp that number is a lot bigger than you intended, so the quotient is rather small.

share|improve this answer
    
What you say makes sense. Originally, I was trying to follow the suggestion made by @HeikoOberdiek at Dividing dimensions to get a count –  A.Ellett Apr 10 at 21:41
    
@A.Ellett the first bullet point in Heiko's answer there is essentially this answer. –  David Carlisle Apr 10 at 21:42
    
That's why I got confused. I thought I was being faithful to his answer. His calculations look like they're being done the same as mine, but his come out correct. –  A.Ellett Apr 10 at 21:45
    
@A.Ellett Heiko's code tends to have that characteristic:-) –  David Carlisle Apr 10 at 21:47
    
@A.Ellett in his example \dimexpr 1pt * \ht\mybox / \textheight\relax he introduces the 2^16 sp scale factor on top and bottom of the quotient a *\ht\mybox takes the height in sp as a number and / \textheight takes \textheight in sp so it cancels out, but you only had one sp length. –  David Carlisle Apr 10 at 21:50
show 1 more 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.