0

I see this sentence on page 21 of the book The TeXbook, but I can't understand it. May you show me an example and explain it to me?

If one of TEX’s internal parameters is changed within a group, the previous contents of that parameter will be restored when the group ends in TeX?.

I think the previous contents of that parameter needn't restore as it never be changed by the parameter.

2 Answers 2

2

Consider an internal parameter such as \baselineskip

If you do

\baselineskip=100pt
{ \baselineskip=5pt }
\showthe\baselineskip

then you will see that \baselineskip is 5pt within the group, but restored to 100pt at the group end.

2

It depends on what you consider an internal parameter. For many of them, the behavior is to respect grouping. But there are a few subtleties.

For instance, hyphenation assignments are always global, so you can't say

{\hyphenation{some-long-word}<text of a paragraph containing somelongword>\par}

and expect that TeX forgets the given hyphenation exception when the group ends.

Similarly font assignments are always global, by which the TeXbook means

\fontdimen<number><font>=<dimen>
\hyphenchar<font>=<number>
\skewchar<font>=<number>

where <font> is a font selector (see the relevant part in the TeXbook).

Box size assignments are a bit weird in this respect. Consider

This is TeX, Version 3.141592653 (TeX Live 2023) (preloaded format=tex)
**\relax

*\newbox\test

*\setbox\test=\hbox{test}

*\showthe\wd\test
> 16.16669pt.
<*> \showthe\wd\test
                    
? 

*\begingroup\wd\test=100pt\endgroup

*\showthe\wd\test
> 100.0pt.
<*> \showthe\wd\test

but the seemingly similar session

This is TeX, Version 3.141592653 (TeX Live 2023) (preloaded format=tex)
**\relax

*\newbox\test

*\setbox\test=\hbox{test}

*\showthe\wd\test
> 16.16669pt.
<*> \showthe\wd\test
                    
? 

*\begingroup\setbox\test=\hbox{different test}\wd\test=100pt\showthe\wd\test
> 100.0pt.
<*> ...fferent test}\wd\test=100pt\showthe\wd\test
                                                  
? 

*\endgroup

*\showthe\wd\test
> 16.16669pt.
<*> \showthe\wd\test

has a different result. The assignment of a width to the box register globally affects the last incarnation of the box. So in the first session the assignment \wd\test=100pt affects the box at the upper level, but in the second session it doesn't.

Also assignments to \spacefactor are inherently global. The same for \prevgraf, \deadcycles and \insertpenalties. There are also dimension parameter that are unaffected by grouping, namely

\prevdepth  \pagegoal  \pagetotal  \pagestretch  \pagefilstretch
\pagefillstretch  \pagefilllstretch  \pageshrink  \pagedepth

that are related to page making.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .