19.5 \spacefactor

Synopsis:

\spacefactor=integer

Influence LaTeX’s glue stretch and shrink behavior. Most user-level documents do not use this command.

While LaTeX is laying out the material, it may stretch or shrink the gaps between words. (This space is not a character; it is called the interword glue; see \hspace). The \spacefactor command (from Plain TeX) allows you to, for instance, have the space after a period stretch more than the space after a word-ending letter.

After LaTeX places each character, or rule or other box, it sets a parameter called the space factor. If the next thing in the input is a space then this parameter affects how much stretching or shrinking can happen. A space factor that is larger than the normal value means that the glue can stretch more and shrink less. Normally, the space factor is 1000. This value is in effect following most characters, and any non-character box or math formula. But it is 3000 after a period, exclamation mark, or question mark, it is 2000 after a colon, 1500 after a semicolon, 1250 after a comma, and 0 after a right parenthesis or bracket, or closing double quote or single quote. Finally, it is 999 after a capital letter.

If the space factor f is 1000 then the glue gap will be the font’s normal space value (for Computer Modern Roman 10 point this is 3.3333 points). Otherwise, if the space factor f is greater than 2000 then TeX adds the font’s extra space value (for Computer Modern Roman 10 point this is 1.11111 points), and then the font’s normal stretch value is multiplied by f /1000 and the normal shrink value is multiplied by 1000/f (for Computer Modern Roman 10 point these are 1.66666 and 1.11111 points).

For example, consider the period ending A man's best friend is his dog. After it, TeX puts in a fixed extra space, and also allows the glue to stretch 3 times as much and shrink 1/3 as much, as the glue after friend, which does not end in a period.

The rules for space factors are even more complex because they play additional roles. In practice, there are two consequences. First, if a period or other punctuation is followed by a right parenthesis or bracket, or right single or double quote then the spacing effect of that period carries through those characters (that is, the following glue will have increased stretch and shrink). Second, if punctuation comes after a capital letter then its effect is not in place so you get an ordinary space. This second case also affects abbreviations that do not end in a capital letter (see \@).

You can only use \spacefactor in paragraph mode or LR mode (see Modes). You can see the current value with \the\spacefactor or \showthe\spacefactor.

(Comment, not really related to \spacefactor: if you get errors like ‘You can't use `\spacefactor' in vertical mode’, or ‘You can't use `\spacefactor' in math mode.’, or ‘Improper \spacefactor’ then you have probably tried to redefine an internal command. See \makeatletter & \makeatother.)


Unofficial LaTeX2e reference manual