8

In texbook.tex the following code is used to fake plain TeX format:

Subsequent paragraphs {\it are\/} indented.*{\spacefactor=3000}
(See?) The computer breaks a paragraph's

Obviously, curly braces are not here to set \spacefactor locally. One reason may be to avoid gobbling the next space.

What is the exact reason of using curly braces here? And is there another way to get the same output?

Is using curly braces the general method to use if we want to set \spacefactor manually?

7

You can read the syntax rules at the bottom of page 277 in the TeXbook.

All of the assignments mentioned so far will obey TeX’s grouping structure; i.e., the changed quantities will be restored to their former values when the current group ends, unless the change was global. The remaining assignments are different, since they affect TeX’s global font tables or hyphenation tables, or they affect certain control variables of such an intimate nature that grouping would be inappropriate. In all of the following cases, the presence or absence of \global as a prefix has no effect.

⟨global assignment⟩ → ⟨font assignment⟩ | ⟨hyphenation assignment⟩
        | ⟨box size assignment⟩
        | ⟨interaction mode assignment⟩
        | ⟨intimate assignment⟩
[...]
⟨intimate assignment⟩ → ⟨special integer⟩⟨equals⟩⟨number⟩
        | ⟨special dimen⟩⟨equals⟩⟨dimen⟩

Now, on page 271 you find what a ⟨special integer⟩ is

⟨special integer⟩ → \spacefactor | \prevgraf
        | \deadcycles | \insertpenalties

Thus \spacefactor=3000 is a global assignment, just like the implicit \spacefactor=1000 assignment that's done when a horizontal list starts off.

Normally one does an explicit assignment to \spacefactor without curly braces. For instance, the \hgl@ macro says \spacefactor\count@. Where's the problem? You surely know it! When TeX is looking for a constant, it stops at a space (that would be gobbled) or at a nonexpandable object that's not a digit (under the current number system, decimal, octal, hexadecimal). The input

.*\spacefactor3000\space\space

would be awkward.

Another way could be .*\afterassignment\space\spacefactor3000 (See?)

Here's the code for checking it.

Subsequent paragraphs {\it are\/} indented.*{\spacefactor=3000}
(See?) The computer breaks a paragraph's

Subsequent paragraphs {\it are\/} indented.*\spacefactor=3000\space\space
(See?) The computer breaks a paragraph's

Subsequent paragraphs {\it are\/} indented.*\afterassignment\space\spacefactor=3000
(See?) The computer breaks a paragraph's

%\tracingall

\bye

In all cases, using \tracingall, you get

...\tenrm *
...\glue 4.44444 plus 4.99997 minus 0.37036
...\tenrm (

enter image description here

9

\spacefactor is a primitive TeX register with "global behavior". There are several TeX registers, they don't respect TeX groups and each assignment to them is global. \spacefactor is an example of this.

Author of cited text wanted simply to keep the following space and he knows that \spacefactor is global. So, he used the cited notation: open group, do global assignment, close group, space.

If group braces are not here then the space after 3000 is consumed by <number> syntax rule.

There is another possibility to achieve the same effect: \spacefactor=3000 \space.

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.