0

Others have asked about getting length as a number; the solutions there (using \strip@pt to remove the units, or using \number to convert to an integer number of sp units) work fine for a regular length but not for one with skip/glue (as described in What is glue stretching?).

For example, the following

\documentclass{article}
\begin{document}
\newlength\testlength
\setlength\testlength{10pt plus 2pt minus 1pt}
length: \the\testlength\par
\textbackslash strip@pt: \csname strip@pt\endcsname\testlength\par
\textbackslash number: \number\testlength\par
\end{document}

prints:

length: 10.0pt plus 2.0pt minus 1.0pt
\strip@pt: 10 plus 2.0pt minus 1.0pt
\number: 655360
0

1 Answer 1

1

Update: Subsequent searching found clues in an answer to "Mathematical description of TeX's infinite numbers?" and "Displaying rubber lengths in arbitrary units". The following

\documentclass{article}
\begin{document}
\newlength\testlength
\setlength\testlength{10pt plus 2pt minus 1pt}
length: \the\testlength\par
\textbackslash dimexpr: \the\dimexpr\testlength\par
\textbackslash gluestretch: \the\gluestretch\testlength\par
\textbackslash gluestretchorder: \the\gluestretchorder\testlength\par
\textbackslash glueshrink: \the\glueshrink\testlength\par
\textbackslash glueshrinkorder: \the\glueshrinkorder\testlength\par
\end{document}

prints:

length: 10.0pt plus 2.0pt minus 1.0pt
\dimexpr: 10.0pt
\gluestretch: 2.0pt
\gluestretchorder: 0
\glueshrink: 1.0pt
\glueshrinkorder: 0

Not the answer you're looking for? Browse other questions tagged .