9

In a comment (emphasis mine)

no, it has to change catcodes and this don't work if they are already frozen

in response to my comment on her answer Ulrike Fischer mentioned the concept of frozen catcodes. For the life of me I have no idea what frozen catcodes could be and so I thought I'd type up a question.

I scoured (searching for instances of freez and froz):

  • TeXbook, p.326: [...] but the glue inside \hbox{...} is frozen at its natural width.
    • also p.173: [...] because these additional braces “freeze” the subformulas, [...]
  • TeX Overview: no mention (just that TeX development was frozen in 1991)
  • TeX for the Impatient ... nothing
  • TeX by Topic ... nothing
  • TikZ & PGF manual (3.1.2): several mentions of "freeze at end" but all referring to TikZ/PGF-specific features
  • Babel manual (3.32): several uses of a \frozen command and one instance of "frozen" inline which is clearly unrelated to the topic at hand
  • Einführung in LuaTeX und LuaLaTeX (by Herbert Voß, in German, ISBN 978-3-86541-530-1): font.frozen ... a boolean in the Font table, mentions of wxLuaFreeze
  • Tabellen mit LaTeX (by Herbert Voß, 3. ed., in German, ISBN 978-3-86541-936-1): "frozen" appears as text
  • Einführung in LaTeX (by Herbert Voß, 3. ed., in German, ISBN 978-3-86541-798-5): several instances of "gefroren" and "erfroren" in the text

(In the German books I also looked for frier and fror which should catch instances of German words corresponding to freeze/frozen.)

Q: So what does this concept of "frozen" entail, what entities does it affect and how do I leverage it in my TeXnical endeavors? Clearly the concept isn't limited to catcodes either ...

  • 1
    The term is not "official", but it's used because it fits the bill. A quote from The TeXBook (Chapter 8. The Characters You Type) which says "frozen" in Knuth's words: "you must remember that characters never change their categories once they have become tokens". And another from Appendix D: "TeX stamps the category on each character when that character is first read from a file". – Phelype Oleinik Jul 5 at 12:55
11

Clearly the concept isn't limited to catcodes either

In all cases except that last one that you link to, "frozen" isn't being used to refer to any technical term referring to a specific definition it is just being used in colloquial English language sense to mean "unchanging".

Catcodes affect the interpretation of characters in the file as they are parsed to generate character tokens which are used by the rest of the macro system. The important thing is that a character token holds both the character code and the cat(egory) code and does not change if the catcode values are changed.

So for example you can do

 .... {\catcode`\&=12 ... & ... } ...

and typeset a normal &

but

 .... \textbf{\catcode`\&=12 ... & ... } ...

will fail as the argument of \textbf will have been parsed first so & will have been read from the file with its normal catcode making it an alignment separator, so when the character token for & is seen as the text is typeset it will generate an error even though the current value of the catcode settings for & at that point has the catcode as 12.

Rather than technical discussion about tokens it is easier to tell people that catcodes are unchanged (or "frozen") once read, which is why \verb and similar commands do not work in the argument of another command.

10

The word frozen is almost always used in a figurative meaning for something that has been saved in a fixed and unmodifiable way (unless somehow unfrozen).

“TeX: the program” (essentially what you get with texdoc tex) uses “frozen” in a very technical meaning. There are some internal control sequences that aren't accessible from the user and cannot be redefined. A common one is the “frozen \relax.

Another common meaning of frozen is for programs that are no longer developed (but perhaps maintained). This is the case of TeX 3.

I'll only mention the references to the TeXbook and babel, adding some for LaTeX.

The passage in the TeXbook about \hbox{...} wants to emphasize that no stretching or shrinking of glue is done. If you do \setbox0=\hbox{a\hfill b}, then \box0 will have ‘a’ and ‘b’ next to each other, because the natural width of \hfill is 0pt. However, the contents of a box register can be unfrozen if you do \unhbox0 (or \unvbox for vertical boxes): a level of boxing is removed and the glue contained in the boxes regain their ability to stretch or shrink.

In a math formula, something between braces (not delimiting an argument) is treated as a subformula which is boxed similarly to \hbox{...} before, so glue inside it will not participate to stretching or shrinking. The subformula itself will be handled as an ordinary atom when boxing the outer formula.

The babel manual has frozen in a footnote about hyphenation. TeX is able to load hyphenation patterns only when it is making a format. When you run pdflatex file, you are actually running

tex &pdflatex file

where & means “load the file called pdflatex.fmt”, which contains a memory dump of TeX in some well defined state. The footnote mentions lccodes and is about a rather technical point. Hyphenation in TeX relies both on patterns and the \lccode array. The status of the array when hyphenation patterns are loaded during format creation is saved in the memory dump together with the digested patterns and is not modifiable.

There are also other frozen things in LaTeX: \frozen@everymath and \frozen@everydisplay, which are internal aliases for the primitive token registers \everymath and \everydisplay. LaTeX then reallocates \everymath and \everydisplay as standard token registers, in order to have a “safe” starting point: for instance \frozen@everymath does \check@mathfonts and it's very important this macro is executed at the beginning of every formula. If \everymath was used, a package code could modify the register and forget to add the important bit. Thus LaTeX has

\let\frozen@everymath\everymath
\newtoks\everymath
\frozen@everymath = {\check@mathfonts\the\everymath}

so doing something like \everymath{\displaystyle} (it's just an example, don't do it) will not clobber the important \check@mathfonts.

Finally, what's a frozen catcode? Nothing special. It's just an idiom to mean that when input is read in by TeX, catcodes are assigned to each character according to the current status of the \catcode array and cannot be modified (unless the token list is tokenized again via \scantokens).

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.