# Does LaTeX redefine [some] TeX primitives?

I read in "What is the difference between TeX and LaTeX?" that LaTeX is a collection of macros (an extension) built on top of TeX. Supposedly, TeX primitives should then behave in LaTeX the same way they do in TeX. However, it seems it is not always the case. In "How is \char processed in math mode?", it is explained why \char behaves in text mode differently from math mode. But this is only in TeX. In LaTeX, however, \char behaves identically in text and math modes, as it can be seen from the following example:

\documentclass{article}
\begin{document}
In text mode, we obtain \char"5. In math mode, we also obtain $\char"5$.
\end{document}


In TeX, the result is different:

In text mode, we obtain \char"5. In math mode, we obtain $\char"5$.
\bye


It seems that some TeX primitives (at least one: \char) are redefined in LaTeX. I would like to know whether TeX primitives must be redefined in LaTeX. If yes, why? Are there other TeX primitives that are redefined in LaTeX? Are not TeX and LaTeX expected to produce the same result on such a simple piece of code (as in the example)?

LaTeX redefines the primitives \input, \end, \-, \/, \underline and, in some contexts, \par. It does not redefine \char, but it uses different math codes.

In plain TeX we see

\mathcode\^^E="023A % \lnot


but LaTeX doesn't assign a mathcode to ^^E (ASCII 5), so the value is as initially, that is, 5.

When TeX processes \char<number> in math mode, it uses the mathcode of the character, just as if the character was directly input. So in plain TeX you get character "3A in family 2 (\lnot); in LaTeX you get character "5 in family 0.

## Redefined primitives

• \input is redefined to allow \input{<filename>};
• \end is redefined to mark the end of environments;
• \- and \/ are redefined for technical reasons;
• \underline is redefined to be also used in text mode.

As far as \par` is concerned, the redefinitions are essential for list-like environments.

## Why does plain TeX assign a math code to ASCII 5?

Because Knuth used extended character sets and his keyboard allowed to directly input ¬ and other characters. So he found it convenient to set math codes for the extended character set.

• Thanks for your amswer. – spyglass007 Aug 10 at 16:50