[Tex/LaTex] dimexpr: multiplication with constant real factor from macro


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.

  \the\dimexpr \linewidth*\const\relax \newline
  \the\dimexpr \linewidth*\numexpr\const\relax\relax \newline

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

Best Answer

\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


So you example will work with


while the format


can only be used if \const is an integer.

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

Related Question