Consider the following MWE:
\documentclass{article}
\usepackage{tikz}
\newlength{\tlen}
\newlength{\tlenB}
\begin{document}
\setlength{\tlen}{2cm}
\typeout{check 1, tlen is: \the\tlen}
\pgfmathsetlength{\tlenB}{2cm}
\typeout{check 1, tlenB is: \the\tlenB}
\setlength{\tlen}{2cm plus 2pt minus 1pt}
\typeout{check 2, tlen is: \the\tlen}
\pgfmathsetlength{\tlenB}{2cm plus 2pt minus 1pt}
\typeout{check 2, tlenB is: \the\tlenB}
\end{document}
It results with this output:
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
...
check 1, tlen is: 56.9055pt
check 1, tlenB is: 56.9055pt
check 2, tlen is: 56.9055pt plus 2.0pt minus 1.0pt
! Package PGF Math Error: Unknown operator `p' or `pl' (in '2cm plus 2pt minus
1pt').
See the PGF Math package documentation for explanation.
Type H <return> for immediate help.
...
l.15 ...hsetlength{\tlenB}{2cm plus 2pt minus 1pt}
So, apparently \pgfmathsetlength
(or pgfmath
in general?) cannot handle glue-type lengths, in particular the plus
and minus
parts.
What option do I have in using glue-type length skip with pgfmath
? If nothing better is possible, then I'd settle for the fixed part only (i.e. I could live with the plus
/minus
stretchable/shrinkable parts being truncated)...
(Note to self: good intro on glues here: What is glue stretching?)
\newlength
are rubber lengths (skips, in TeXbook terminology), while\pgfmathsetlength
is only able to cope with rigid lengths (\dimen
registers). Unfortunate clash of terms. – egreg Sep 1 '14 at 21:12