# Test if a skip has an infinite stretch/shrink component

I want to implement an if-then-else depending on whether a skip contains a special character or not.

So far, I tried the idea: convert the skip to a token list, and check if the letter f is in the list. Something like this:

\leftskip=10pt plus1fil\relax
\edef\mystring{\the\leftskip\the\rightskip}
\if\instring{f}{\mystring}\message{YES}\else\message{NO}\fi
\def\mystring{10.0pt plus 1.0fil}
\if\instring{f}{\mystring}\message{YES}\else\message{NO}\fi
\message{\the\leftskip}


I use \mystring as defined here: Check if a string contains a given character

Unfortunately, the code does not work. The log file contains contains NO instead of YES:

NO
YES
10.0pt plus 1.0fil


Probably I know what is wrong, but it is time to ask for a better idea: how to detect infinity?

The catcode of f is 11 for "letter". However, the tokens output by \the have catcode 12 (other character) with the exception of the space with catcode 10. For your comparison the catcode of f can be "converted" to 12 by \string:

\if\expandafter\instring\string f{\mystring}


## Test with e-TeX

e-TeX provides \gluestretchorder and \glueshrinkorder return the order of infinity, e.g. the values of \gluestretchorder reflects the infinity of the plus component:

• 0: no fil, fill, ...
• 1: fil
• 2: fill
• 3: filll

The following way can be tested, whether a skip contains an infinite stretch component (using \leftskip as example for a skip register):

\ifnum\gluestretchorder\leftskip>0 %
\message{YES}%
\else
\message{NO}%
\fi

• Thanks you, I'm very happy to learn about glueorder-commands. – olpa May 24 '13 at 17:01