TeX Core Concepts
TeX is a program that typesets boxes. TeX builds pages based on boxes and glue. Each character is a box which is glued to other letters to form words. The glue is elastic so it can be manipulated to fill the page optimally. Boxes may be contained by other boxes.
A control character (non-printing character) is a code point (a number) in a character set, that does not represent a written symbol.
\ followed by a sequence of control characters.
- TeX primitives are native commands:
- macros are sequences defined with
- registers are variables to save values:
- character constants are sequences declared by the primitives
- font selectors are sequences declared by the primitive
An undefined control sequence is any control sequence which has no meaning assigned to it.
TeX has for primitive box control sequences.
\vboxvertical box with reference point at the last item inside it.
\vtopvertical box with reference point at the first item inside it.
\vcentervertical box with reference point in the middle.
The baseline of a box is a vertical line that divides the box. It is used as a reference point for placing things in the box. Characters like
'x' start at or slightly above the baseline and never cross it. Other characters like
'y' rest on the baseline and its tail crosses it.
The distance from the baseline to the top of the box.
The distance from the baseline to the bottom of the box.
The horizontal length of a box.
Where the baseline and the left-side of the box meet.
Badness is a measure for the quality of a box made by TeX. It is an integer value between 0 and 10000.
\badness is set by TeX each time it constructs a box. If there is an overflow error then
\badness is set to 1000000.
TeX could not produce a result that does not overfill a box. This is generally do to a justification or hyphenation error.
TeX could not appropriately fill the box. TeX could not stretch the box wide enough without making the space bigger than permitted.
In TeX, characters are stored in boxes like every printed element.
Glue is the white space between boxes. Glue can expand and contract during the construction to give optimal positioning for boxes. At some point becomes set and cannot change. It is displayed as white space.
When processing a
tex source file,
TeX operates in one of the following modes.
TeX stack boxes on top of each other in vertical lists.
internal vertical mode
TeX builds a vertical list for a vbox.
TeX stacks boxes next to each other in horizontal lists.
restricted horizontal mode
TeX builds a horizontal list for a hbox. No line break allowed.
TeX builds a mathematical formula for a horizontal list.
display math mode
TeX builds a mathematical formula to be placed on a line itself. This interrupts the current paragraph.
A macro is a rule that specifies how a control sequence should be mapped to a replacement output sequence. The primitive control sequence
\def allows us to define new macros. Macros support up to nine arguments.
The first argument must be delimited by two square brackets while the second may be a single character.
Originally intended to use its own font system, MetaFont. Computer Modern is the default font system for TeX. These are high quality, scalable fonts. MetaFont is a complex font system. Most modern TeX compilers allow for the use of external font systems such as Truetype font (ttf) and OpenType font (otf).
When TeX parses an input, it assigns it a category code. TeX uses the character and its category to determine how to interpret it. These are used as primitive commands for common tasks.
There are sixteen category codes:
- 0 = escape
- 1 = group start
- 2 = group end
- 3 = math shift
- 4 = alignment tab
- 5 = end of line
- 6 = parameter for macros
- 7 = math superscript
- 8 = math subscript
- 9 = ignored character
- 10 = space
- 11 = letters of the alphabet
- 12 = other character
- 13 = active character
- 14 = comment
- 15 = invalid character
TeX has 25 keywords. There are no backslashes before them. TeX interprets them depending on the mode.
at dd fill mm sp by depth filll mu spread bp em height pc to cc ex in plus true cm fil minus pt width
TeX has 325 primitive control sequences.