I'd like to create a custom command which creates an underscore of a given length. However, this length should be the argument of the command multiplied be a floating point constant.
How can I multiply the argument of a command within the command's definition?
The code without the multiplication looks like this:
\newcommand{\utext}[2]{$\underset{\mbox{\tiny #1}}{\underline{\hspace{#2cm}}}$}
Instead of the \hspace
of #2cm
it should be something like (0.75 * #2)cm
Best Answer
There are two ways for solving the problem.
First (and recommended):
In this way,
#2
can be any decimal number.Second, trickier:
Why do I recommend the first way? You can use
\threequarters
wherever you want and change its width by acting just in one place, instead of looking for0.75
across your definitions.However, also the second solution is "parametrisable", by doing
and using
\hspace{\threequarterfactor\dimexpr#2cm\relax}
in the definition. I still prefer reserving a length.