I have some understanding on how to use length registers for calculations. However, I always end up requiring way too many length registers for tasks which could probably be solved better by expressions. How can avoid the use of so many registers?
To make things more precise: I have a MWE, which does what I want:
\documentclass{article}
\usepackage{calc}
\def\cone{CONTENT ONE}
\def\ctwo{CONTENT TWO}
\begin{document}
\newdimen\coneheight
\newdimen\conewidth
\newdimen\ctwoheight
\settoheight{\coneheight}{\cone}
\settowidth{\conewidth}{\cone}
\settoheight{\ctwoheight}{\ctwo}
\newdimen\scaled
\setlength{\scaled}{\dimexpr \numexpr \ctwoheight * \conewidth / \coneheight \relax sp\relax}
Result: \the\scaled
\end{document}
What I am think of is something like this:
\usepackage{calc}
\def\cone{CONTENT ONE}
\def\ctwo{CONTENT TWO}
\begin{document}
\newdimen\better
\setlength{\better}{\dimexpr \numexpr \heightof{\ctwo} * \widthof{\cone} / \heightof{\cone} \relax sp\relax}
Better: \the\better
\end{document}
but unfortunately this code barks at me in all possible kinds...which I do not understand, since I am actually only replacing length registers by length expressions. Or not?
What am I doing wrong and how can I end up in a more compact expression style which avoids placing all lengths into registers?