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
\def\mystring{10.0pt plus 1.0fil}

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:

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?

1 Answer 1


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 %
  • Thanks you, I'm very happy to learn about glueorder-commands.
    – olpa
    May 24, 2013 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.