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 want to multiply a constant from a macro with a deimension using dimexpr. When using real numbers the decimal point and the decimal digits are typeset behind the result and the result is a mutliplication with the floor value of the constant used.

\documentclass{report}
\begin{document}
  \def\const{1.9}
  \noindent
  \the\dimexpr \linewidth*\const\relax \newline
  \the\dimexpr \linewidth*\numexpr\const\relax\relax \newline
  \the\linewidth
\end{document}

The second multiplication is an attempt to use the suggestion from here, to wrap the macro in a sub expression

share|improve this question
    
I've answered, but the answer you link to does include more-or-less the same points. This question therefore might be marked as a duplicate. –  Joseph Wright Aug 1 '13 at 13:07
    
@JosephWright: just mark it as a duplicate, I don't mind. I overlooked it since I skimmed the awnser and read the bottom part, starting Real numbers can be supported by ... thats why I wondered where I went wrong. I am propably used by pgfs math capabilities. –  ted Aug 1 '13 at 13:12
    
Looking again I think probably not a dupe: the questions have a different focus (the other one on what to do to avoid repeated addition, here about the syntax of multiplication). –  Joseph Wright Aug 1 '13 at 13:49
add comment

1 Answer

up vote 5 down vote accepted

\dimexpr doesn't allow arbitrary calculations: you need to have things in the correct form. In particular, if you want to multiply a dimension by a decimal then you need to use the form

<multiple><dimension>

So you example will work with

\the\dimexpr\const\linewidth\relax

while the format

\the\dimexpr\linewidth*\const\relax

can only be used if \const is an integer.

(The linked answer Multiplication with dimexpr? does mention this limitation.)

share|improve this answer
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.