1

Since the character ~ has a catcode of 13, it is considered active. I can (ab)use this by executing something like the code \let~\catcode ~`a8 which assigns the character a a catcode of 8 (for subscript), without having to do \catcode`~13 first.

What other characters are considered active by default in TeX? In other words, what characters have a catcode of 13 by default?

btshepard
  • 680
  • 1
    ~ is the only one usable in latex. In pdftex all characters above 127 are active but if you mess with them you will break the encoding support. – David Carlisle May 20 '22 at 23:21
  • 1
    Just noting that your question title says "always active", while your question says "active by default". These are not the same thing, since the catcode of ~ can be changed on a whim. – Steven B. Segletes May 20 '22 at 23:26
  • Good catch, changed. – btshepard May 20 '22 at 23:53
  • Looks like a rather impractical question, but you can just do a loop to print out catcode of every characters. Last time I check, the discretionary hyphen ("A0) is in non-pdflatex engine. – user202729 May 21 '22 at 07:37

1 Answers1

3

plain always has character 12 (form feed) and 126 (tilde) as active which is not surprising.

In LaTeX the situation depends on the engine used. With pdflatex characters 128-225 are active for encoding support; in xelatex and lualatex character 173 (U+00AD "soft hyphen") is declared active and given the meaning \- (discretionary hyphen).

In table form:

format / engine tex pdftex xetex luatex
plain 12 126 12 126 12 126 12 126
LaTeX / 1-8 11 12 14-31 126 128-255 12 126 173 12 126 173
conTeXt / / / 124 126
AmS-TeX / 12 64 126 / /
OpTeX / / / 126 160

Overall only ~ seems to be universal.

The following test file is used:

\ifx\documentclass\undefined \else
    \documentclass{article}
    \begin{document}
\fi
\csname starttext\endcsname

\newcount\curr \newcount\upper

\ifx\numexpr\undefined \upper="100 \def\n{^^J} \else \ifx\pdftexbanner\undefined \upper="10000 \edef\n{\Uchar"000A} \else \upper="100 \def\n{^^J} \fi \fi

\newlinechar=10 \message{\n\n}

\count0=0 \loop \ifnum\catcode\curr=\active \message{ \the\curr} \fi \advance\curr 1 \ifnum\curr<\upper \repeat

\message{\n\n}

\csname stoptext\endcsname \end{document}

plante
  • 1,349