2

I am representing actual object dimensions with scaled down graphics which capture the relative proportions of the objects (for instance, imagine a simple set of three or four line segments). I would like to annotate the length of a nominal segment on the graphic using that segments actual length. I store the actual lengths using the \newlength and \setlength commands. I apply a suitable scaling factor to these segments by operating on the declared actual lengths in order to compute lengths as they should appear in print. This link provides several possible solutions, e.g.

\newcommand*{\getlength}[2]{%
   % Convert to `cm` and round to two fractional digits:
   \pgfmathsetmacro#1{round(3.51459804*#2)/100.0}%
}

When I provide a value of 180 cm

\newlength{\lengtha}
\setlength{\lengtha}{180cm}
\getlength{\annotlengtha}{\lengtha}

I encounter some restriction, that is, I receive a Dimension too large error message. Might someone explain the limitations associated with this approach?

1 Answers1

2

Somewhere on this site, Dividing dimensions to get a count, percusse explained how egreg taught him (and now me) to turn lengths into dimensionless numbers using "count" variable types. One can assign a length to the count, and it turns it into a large integer (representing the length in TeX internal units).

Then, you can divide two counts to get a dimensionless ratio, for example. A size of 180cm poses no problem for this technique.

\documentclass{article}
\usepackage{fp}
\begin{document}
\newcount\mycounta
\newcount\mycountb
\newlength{\lengtha}
\setlength{\lengtha}{180cm}
\newlength{\lengthb}
\setlength{\lengthb}{30cm}
\mycounta=\lengtha
\mycountb=\lengthb
\the\mycounta~\the\mycountb

\FPdiv\result{\the\mycounta}{\the\mycountb}
\result

\end{document}

enter image description here