% $Id: concepts.tex,v 1.5 2020/01/01 23:55:26 karl Exp $
% This is part of the book TeX for the Impatient.
% Copyright (C) 2003-2020 Paul W. Abrahams, Kathryn A. Hargreaves, Karl Berry.
% See file fdl.tex for copying conditions.

\input macros
\chapter{Concepts}

\chapterdef{concepts}

This part of the book contains definitions and explanations of 
the concepts that we use in describing \TeX.
The concepts include both
technical terms that we use in explaining the commands and
important topics that don't fit elsewhere in the book.

The concepts are arranged alphabetically.
The inside back cover of the book contains a complete list of
concepts and the pages on which they are explained.
We suggest that you make a copy of the inside back cover and keep it nearby
so that you'll be able to identify and look up an unfamiliar
concept immediately.
As far as possible, we've kept our terminology consistent with that of
\texbook.\idxref{\texbook}

\beginconcepts

\conceptindex{active characters}
\concept {active character}

An \defterm{active character} is a \refterm{character}
that has a definition, e.g., a macro definition, associated with it.  
^^{macros//named by active characters}
You can think of an active character as a special kind of control sequence.
When \TeX\ encounters an active character, it
executes the definition associated with the character.
If \TeX\ encounters an active character that does not have
an associated definition, it will complain about an
undefined control sequence.

An active character has a \refterm{category code} of $13$ (the value
of ^|\active|).
To define an active character, you should first
use the ^|\catcode| command
\ctsref{\catcode} to make it active
and then provide the definition of the character, using
a command such as |\def|, |\let|, or |\chardef|.
The definition of an active character has the same form as
the definition of a \refterm{control sequence}.
^^{category codes//of active characters}
If you try to define the macro for an active character
before you make the character active, \TeX\ will complain about a 
missing control sequence.  

For example, the tilde character (|~|) is defined as an active character
in \plainTeX.  It
produces a space between two words but links those words so that 
\TeX\ will not turn the space into a \refterm{line break}.
\refterm{\PlainTeX:\plainTeX} defines `|~|' by the commands:

\csdisplay
\catcode `~ = \active \def~{\penalty10000\!visiblespace}
|
(The |\penalty| inhibits a line break and the `|\!visiblespace|'
inserts a space.)
\endconcept


\conceptindex{alignments}
\concept alignment

\bix^^{tables}
An \defterm{alignment} is a construct for aligning material, such as a
table, in columns or rows.  To form an alignment you need to
(a)~describe the layout of the columns or rows and (b)~tell \TeX\ what
material goes into the columns or rows.  A tabbing alignment or a
horizontal alignment is organized as a sequence of rows; a vertical
alignment is organized as a sequence of columns.  We first describe
tabbing and horizontal alignments and then more briefly describe
vertical alignments.

Tabbing alignments are defined by \plainTeX.  They are simpler but less
flexible than horizontal alignments.  Tabbing and horizontal alignments
differ principally in how you describe their layouts.

\bix^^|\settabs|
\bix\ctsidxref{+}
\bix\ctsidxref{cr}

To construct a tabbing alignment you first issue a |\settabs| command
\ctsref{\settabs} that specifies how \TeX\ should divide the available
horizontal space into columns.  Then you provide a sequence of rows for
the table.  Each row consists of a |\+| control sequence \ctsref{\@plus}
followed by a list of ``entries'', i.e., row\slash column intersections.
^^{entry (column or row)}
Adjacent entries in a row are separated by an ampersand (|&|).
\xrdef{@and}
\ttidxref{&}
The end of a row is indicated by ^|\cr| after its
last entry. 
If a row has fewer entries than there are columns in the alignment,
\TeX\ effectively fills out the row with blank entries.

As long as it's preceded by a |\settabs| command, you can put a row of a
tabbing alignment anywhere in your document.  In particular, you can put
other things between the rows of a tabbing alignment or describe several
tabbing alignments with a single |\settabs|.  Here's an example of a
tabbing alignment:

\xrdef{tabbedexample}\csdisplay
{\hsize = 1.7 in \settabs 2 \columns
\+cattle&herd\cr
\+fish&school\cr
\+lions&pride\cr}
|
The |\settabs 2 \columns| command in this example \ctsref{\settabs}
tells \TeX\ to produce two equally wide columns.
The line length is $1.7$ inches.
The typeset alignment looks like this:

{\def\+{\tabalign}% so it isn't \outer.
\vdisplay{%
\hsize 1.7 in \settabs 2 \columns
\+cattle&herd\cr
\+fish&school\cr
\+lions&pride\cr}
}%

\margin{Missing explanation added here.}
There's another form of tabbing alignment in which you specify the column
widths with a template.  The column widths in the template
determine the column widths in the rest of the alignment:
\csdisplay
{\settabs\+cattle\quad&school\cr
\+cattle&herd\cr
\+fish&school\cr
\+lions&pride\cr}
|
Here's the result:
{\def\+{\tabalign}% so it isn't \outer.
\vdisplay{%
\settabs\+cattle\quad&school\cr
\+cattle&herd\cr
\+fish&school\cr
\+lions&pride\cr}
}%

\eix^^|\settabs|
\eix\ctsidxref{+}
\bix^^|\halign|
Horizontal alignments are constructed with |\halign| \ctsref\halign.
\TeX\ adjusts the column widths of a horizontal alignment according to
what is in the columns.  When \TeX\ encounters the |\halign| command
that begins a horizontal alignment, it first examines all the rows of
the alignment to see how wide the entries are.  It then sets each column
width to accommodate the widest entry in that column.

A horizontal alignment governed by |\halign| consists of a
``\pix^{preamble}'' that indicates the row layout followed by the rows
themselves.
\ulist
\li The preamble consists of a sequence of \pix^{template}s, one for each
column.  The template for a column specifies how the text for that
column should be typeset.  Each template must include a single |#|
character
\ttidxref{#}\xrdef{@asharp}
to indicate where \TeX\ should substitute the text of an entry into the
template.  The templates are separated by ampersands (|&|), \ttidxref{&}
and the end of the preamble is indicated by |\cr|.  By providing an
appropriate template you can obtain effects such as centering a column,
left or right justifying a column, or setting a column in a particular
\refterm{font}.

\li The rows have the same form as in a tabbing alignment, except that
you omit the |\+| at the beginning of each row.
As before, entries are separated by |&| and the end of the row
is indicated by |\cr|.
\TeX\ treats each entry as a 
\refterm{group}, so any
font-setting command or other \refterm{assignment}
in a column template is in effect only for the entries in that column.
\endulist
\noindent The preamble and the rows must all be enclosed in the braces
that follow |\halign|.  Each |\halign| alignment must include
its own preamble.

For example, the horizontal alignment:
\csdisplay
\tabskip=2pc
\halign{\hfil#\hfil &\hfil#\hfil &\hfil#\hfil \cr
  &&\it Table\cr
\noalign{\kern -2pt}
  \it Creature&\it Victual&\it Position\cr
\noalign{\kern 2pt}
  Alice&crumpet&left\cr
  Dormouse&muffin&middle\cr
  Hatter&tea&right\cr}
|

\noindent produces the result:

\xrdef{halignexample}
\vdisplay{%
\tabskip=2pc \halign{\hfil#\hfil &\hfil#\hfil &\hfil#\hfil \cr
  &&\it Table\cr
\noalign{\kern -2pt}
  \it Creature&\it Victual&\it Position\cr
\noalign{\kern 2pt}
  Alice&crumpet&left\cr
  Dormouse&muffin&middle\cr
  Hatter&tea&right\cr}
}%
\noindent The ^|\tabskip| \ctsref{\tabskip} in this example 
tells \TeX\ to insert |2pc| of 
\refterm{glue} between the columns.
The ^|\noalign| \ctsref{\noalign} commands tell \TeX\ to insert
\refterm{vertical mode} material between two rows.
In this example we've
used |\noalign| to produce some extra space between the title rows and
the data rows, and also to bring ``Table'' and ``Position'' closer together.
(You can also use |\noalign| before the first row or after the
last row.)
\eix^^|\halign|

You can construct a vertical alignment with the ^|\valign| command
\ctsref{\valign}.  A vertical alignment is organized as a series of
columns rather than as a series of rows.  A vertical alignment follows
the same rules as a horizontal alignment except that the roles of rows
and columns are interchanged.  For example, the vertical alignment:

\csdisplay
{\hsize=0.6in \parindent=0pt
\valign{#\strut&#\strut&#\strut\cr
  one&two&three\cr
  four&five&six\cr
  seven&eight&nine\cr
  ten&eleven\cr}}
|
\noindent yields:
\vdisplay{%
{\hsize=0.6in \parindent=\listleftindent % Because lists and displays
                                         % are not indented just by \parindent.
\valign{#\strut&#\strut&#\strut\cr
  one&two&three\cr
  four&five&six\cr
  seven&eight&nine\cr
  ten&eleven\cr}}
}
The ^|\strut| commands \ctsref{\strut} 
in the template are necessary to get the entries in each row
to line up properly, i.e., to have a common \refterm{baseline},
and to keep the distance between baselines uniform.
\eix\ctsidxref{cr}
\eix^^{tables}

\endconcept


\concept{\anatomy}

\texbook\ describes the way that {\TeX} processes its input in terms of \TeX's
``digestive tract''---its ``^{eyes}'', ``^{mouth}'',
``^{gullet}'', ``^{stomach}'', and ``^{intestines}''.  Knowing how this
processing works can be helpful when you're trying to understand subtle
aspects of \TeX's behavior as it's digesting a document.

\ulist

\li Using its ``\pix^{eyes}'', \TeX\ reads \refterm{characters:character} from
^{input files} and passes them to its mouth.  Since an input file
can contain ^|\input| commands \ctsref{\input},
\TeX\ can in effect ``shift its gaze'' from one file to another.

\li Using its ``\pix^{mouth}'', {\TeX} assembles the characters into
\refterm{tokens:token} and passes them to its gullet.
Each token is either a \refterm{control sequence} or a single
character.  A control sequence always starts with an \refterm{escape
character}.  Note that spaces and ends-of-line are characters in their
own right, although \TeX\ compresses a sequence of input spaces into a single
space token.  See \knuth{pages~46--47} for the rules by which \TeX\ assembles
characters into tokens.
^^{tokens//assembled from characters}

\li Using its ``\pix^{gullet}'', {\TeX} expands any macros, conditionals, and
^^{macros//expanded in \TeX's stomach}
^^{tokens//passed to \TeX's stomach}
similar constructs that it finds (see \knuth{pages~212--216}) and passes
the resulting sequence of \refterm{tokens:token}
to \TeX's stomach.  Expanding one token
may yield other tokens that in turn need to be expanded.  {\TeX} carries
out this expansion from left to right unless the order is modified by
a command such as |\expandafter| \ctsref{\expandafter}.
In other words, \TeX's gullet always expands the leftmost un\-ex\-panded
token that it has not yet sent to \TeX's stomach.

\li Using its ``\pix^{stomach}'', {\TeX} processes the tokens in
groups.
Each group contains a primitive command followed by its arguments, if any.
Most of the commands are of the ``typeset this character'' variety,
so their groups consist of just one token.
Obeying the instructions given by the commands,
\TeX's stomach assembles larger and larger 
units, starting with 
characters and ending with pages,
and passes the pages to \TeX's intestines.
^^{pages//assembled in \TeX's stomach}
\TeX's stomach handles the tasks of \refterm{line break}ing---%
^^{line breaking}
i.e., breaking each paragraph into a sequence of lines---%
and of \refterm{page break}ing---i.e., breaking a continuous sequence of lines
and other vertical mode material
into pages. 

\li Using its ``\pix^{intestines}'', \TeX\ transforms the pages produced by its
stomach into a form intended for processing
by other programs.  It then sends the transformed output to the 
\dvifile.
^^{\dvifile//created by \TeX's intestines}

\endulist

Most of the time you can think of the processes that take place in \TeX's
eyes, mouth, gullet, stomach, and intestines 
as happening one after the other.  But the 
truth of the matter is that commands executed in \TeX's stomach can
influence the earlier stages of digestion.  For instance, when \TeX's stomach
encounters the |\input| command \ctsref{\input}, 
its eyes start reading from a different
file; when \TeX's stomach encounters a |\catcode| command
 \ctsref{\catcode} specifying a category code
for a character $c$, the interpretation of $c$ by \TeX's mouth is affected.
And when
\TeX's stomach encounters a \refterm{macro} definition, the expansions carried
out in \TeX's gullet are affected.

You can understand how the processes interact by imagining that each
process eagerly gobbles up the output of its predecessor as soon as it
becomes available.  For instance, once \TeX's stomach has seen
the last character of the filename in an |\input| command, \TeX's gaze
immediately shifts to the first character of the specified input file.
\endconcept

\pagebreak
\conceptindex{arguments}
\concept argument

^^{commands//arguments of}
An \defterm{argument} contains text that is passed to a
\refterm{command}.
The arguments of a command complete the description of what
the command is supposed to do.
The command can either be a \refterm{primitive} command or a 
\refterm{macro}.

Each primitive command ^^{primitive//command}
has its own convention about the form of its
arguments.  For instance, the sequence of \refterm{tokens:token}:

\csdisplay
\hskip 3pc plus 1em
|
consists of the command `|\hskip|' and the arguments
`|3pc plus 1em|'.  But if you were to write:

\csdisplay
\count11 3pc plus 1em
|
you'd get an entirely different effect.
\TeX\ would treat `|\count11|' as a command with argument `|3|',
followed by the ordinary text tokens `|pc plus 1em|'
(because count registers expect a number to be assigned to them)%
---probably not what
you intended.  The effect of the command, by the way, would be to
assign $3$ to count register $11$ (see the discussion of ^|\count|,
\xref\count).

Macros, on the other hand, all follow the same convention
for their arguments.
^^{macros//arguments of}
Each argument passed to a macro
corresponds to a \refterm{parameter}
^^{parameters//and arguments}
in the definition of that
macro. ^^{macros//parameters of}
A macro parameter is either ``delimited'' or ``undelimited''.
The macro definition determines the number and nature of the macro parameters
and therefore the number and nature of the macro arguments.

The difference between a delimited argument and an undelimited argument
lies in the way that \TeX\ decides where the argument ends.
^^{delimited arguments}
^^{undelimited arguments}
\ulist
\li A delimited argument consists of the tokens
from the start of the argument up to, but not including, the
particular sequence of tokens that serves as the delimiter for that argument.
The delimiter is specified in the macro definition.  Thus you 
supply a delimited argument to a macro by writing the argument itself
followed by the delimiter.  A delimited argument can be empty, i.e., have
no text at all in it.  Any braces in a delimited argument must be paired
properly, i.e., every left brace must have a corresponding right brace
and vice versa.

\li An undelimited argument consists of a single token or a sequence of
tokens enclosed in braces, like this:
`|{Here is {the} text.}|'.  Despite appearances, the outer braces don't
form a \refterm{group}---\TeX\ uses them only to determine what the
argument is.  Any inner braces, such as the ones around `|the|', must be
paired properly.  If you make a mistake and put in too many right
braces, \TeX\ will complain about an unexpected right brace.  \TeX\ will
also complain if you put in too many left braces, but you'll probably
get \emph{that} complaint long after the place where you intended to
end the argument (see \xref{mismatched}).
\endulist
\noindent 
See \conceptcit{macro} for more information
about parameters and arguments.  You'll find the precise rules pertaining
to delimited and undelimited arguments in \knuth{pages~203--204}.
\endconcept


\concept{ASCII}

\defterm{\ascii} is the abbreviation of ``American Standard Code for
Information Interchange''.  There are $256$ \ascii\
^{characters}, each with its own code number, but
the meanings of only the first~$128$ have been standardized.  You can
find these meanings in an \ascii\ ``code table'' such as the one on
\knuth{page~367}.  Characters $32$--$126$ are ``printable characters'',
^^{printable characters} such as letters, numbers, and punctuation
marks. The remaining characters are ``^{control characters}'' that are
typically used (in the computer industry, not in \TeX) to control
input\slash output and data communications devices.  For instance,
\ascii\ code $84$ corresponds to the letter `T', while \ascii\
code~$12$ corresponds to the ``form feed'' function (interpreted by most
printers as ``start a new page'').  Although the \ascii\ standard
specifies meanings for the control characters, many manufacturers of
equipment such as modems and printers have used the control characters
for purposes other than the standard ones.

The meaning of a
character in \TeX\ is usually consistent with its meaning in standard \ascii,
and \refterm{fonts:font} that contain \ascii\
printable characters usually have those characters in the same positions as
their \ascii\ counterparts.
But some fonts, notably those used for math, replace the \ascii\
printable characters by other characters unrelated to the \ascii\ characters.
For instance, the Computer Modern math font
^^{Computer Modern fonts}
|cmsy10| has the math symbol
`{$\forall$}' in place of the \ascii\ digit `8'.


\endconcept

\conceptindex{assignments}
\concept assignment

An \defterm{assignment} is a construct that tells \TeX\ to assign a
value to a register,
^^{registers//assignment to}
to one of its internal
\refterm{parameters:parameter},
^^{parameters//assignments to}
to an entry in one of its internal tables,
or to a \refterm{control sequence}. Some examples of assignments are:

\csdisplay
\tolerance = 2000
\advance\count12 by 17
\lineskip = 4pt plus 2pt
\everycr = {\hskip 3pt \relax}
\catcode\`@ = 11
\let\graf = \par
\font\myfont = cmbx12
|

The first assignment indicates that \TeX\ should assign the numeric value
|2000| to the numeric parameter |\tolerance|, i.e., make the value of
|\tolerance| be $2000$.  The other assignments are similar.  The `|=|'
and the spaces are optional, so you could also write the first
assignment more tersely as:

\csdisplay
\tolerance2000
|

See \knuth{pages~276--277} for the detailed syntax of assignments.
\endconcept


\concept badness

The \defterm{badness} of a line is a measure of how far the interword
spaces ^^{interword spacing}
in the line deviate from their natural values,
i.e., the values specified in the \refterm{fonts:font} used in the line.
The greater the
deviation, the greater the badness.  Similarly, the badness of a page is
a measure of how far the spaces between the boxes that
make up the page deviate from their ideal values.  (Ordinarily, most of these
boxes are single lines of paragraphs.)

More precisely, the badness
is a measure of how much the \refterm{glue} associated with these spaces needs
to stretch or shrink to fill the line or page exactly.
\TeX\ computes the badness as approximately $100$
times the cube of the ratio by which it must stretch or shrink the glue
in order to compose a line or a page of the required size.
^^{line breaks//badness for}^^{page breaks//badness for}
For example, stretching the glue by twice its stated stretch yields a ratio of
$2$ and a badness of $800$; stretching it by half its stated stretch yields
a ratio of $.5$ and a badness of $13$.
\TeX\ treats a badness greater than $10000$ as
equal to $10000$.

\TeX\ uses the badness of a line when it's breaking a paragraph into lines
\seeconcept{line break}.  It uses this information in two stages:

\olist
\li When \TeX\ is choosing line breaks,
it will eventually accept lines whose badness is less than or equal to
the value of |\tolerance| (\xref \tolerance).  If \TeX\ cannot avoid setting
a line whose badness exceeds this
value, it will set it as an underfull or overfull \refterm{hbox}.
\TeX\ will set
an overfull or underfull hbox only as a last resort, i.e., only if there's no
other way to break the paragraph into lines.
\li Assuming that all lines are tolerably bad, \TeX\ uses the badness of lines
in order to evaluate the different ways of breaking the paragraph into lines.
During this evaluation it associates ``demerits'' with each potential line.
The badness increases the number of \refterm{demerits}.
\TeX\ then
breaks the paragraph into lines in a way that minimizes the 
total demerits for the paragraph.
Most
often \TeX\ arranges the paragraph in a way that minimizes the badness of the
worst line.  See \knuth{pages~97--98} for the details of how \TeX\
breaks a paragraph into lines.  
\endolist

\TeX's procedure for assembling a sequence of lines and other vertical
mode material into pages is similar to its procedure for line breaking.
However, assembling pages is
not as complicated because \TeX\ only considers one page at a time
when it looks for page breaks.
Thus the only decision it must make is where to end the current page.
In contrast, when \TeX\ is choosing line breaks it 
considers several of them simultaneously.
(Most word processors choose line breaks one at a time,
and thus don't do as good a job at it as \TeX\ does.)
See \knuth{pages~111--113} for the details of how \TeX\ chooses its
page breaks.
\endconcept


\conceptindex{baselines}
\concept baseline

The \defterm{baseline} of a \refterm{box} is an imaginary line that runs
across the box.
^^{boxes//baselines of}
When \TeX\ is
assembling the boxes of a \refterm{horizontal list} into a larger box,
it lines up the boxes in the list so that their baselines coincide.
As an analogy, think of writing on a pad of ruled paper.  Each letter 
that you write has
an implicit baseline.
In order to line up the letters horizontally,
you place them on the pad so that their baselines
agree with the light guidelines that are printed on the pad.

A box can and often does extend below its baseline.
For instance, the letter `g' extends below the baseline of its box because
it has a descender (the bottom loop of the `g').
\endconcept


\conceptindex{boxes}
\concept box

A \defterm{box}  is a rectangle of material to be typeset.  A single
\refterm{character} is a box by itself,
and an entire page is also a box.
\TeX\ forms a page as a nest of boxes within boxes within boxes. The
outermost box is the page itself, the innermost boxes are mostly
single characters, and single lines are boxes that are
somewhere in the middle.

\TeX\ carries out most of its box-building activities implicitly as it
constructs paragraphs and pages.
You can construct boxes explicitly
using a number of \TeX\ \refterm{commands}, notably 
^|\hbox| \ctsref{\hbox},
^|\vbox| \ctsref{\vbox}, and
^|\vtop| \ctsref{\vtop}.
The ^|\hbox| command
constructs a box by appending smaller boxes horizontally from left to right;
it operates on a \refterm{horizontal list} and yields
an \refterm{hbox} ^^{hboxes} (horizontal box).
^^{horizontal lists}
The ^|\vbox| and |\vtop| commands
construct a box by appending smaller boxes vertically from top to bottom;
^^{vboxes}
they operate on a \refterm{vertical list}
and yield a \refterm{vbox} ^^{vboxes} (vertical box).
^^{vertical lists}
These horizontal and vertical lists can include not just smaller boxes but
several other kinds of entities as well, e.g.,  \refterm{glue} and
kerns.
^^{kerns//as list items}

A box has \refterm{height}, \refterm{depth}, and \refterm{width},
^^{height} ^^{depth} ^^{width}
like this:
\vdisplay{\offinterlineskip\sevenrm
   \halign{#&#&\kern3pt \hfil#\hfil\cr
      &\hrulefill\cr
      &\vrule
         \vtop to .7in{\vss \hbox to .9in{\hss baseline\hss}\vskip4pt}%
       \vrule
      &\labelledheight{.7in}{height}\cr
      %
       \vbox to 0pt{
          \vss
          \hbox{reference point \hbox to 15pt{\rightarrowfill}%
          \hskip3pt}%
       \kern-4.5pt}&{\box\refpoint}\hrulefill\cr
      %
      \omit
      &\vrule\hfil\vrule
      &\labelledheight{.4in}{depth}\cr
      %
      &\hrulefill\cr
      %
   \noalign{\vskip3pt}%
      &\leftarrowfill { width }\rightarrowfill\cr
}}

^^{baselines}
The \refterm{baseline} is like one of
the light guidelines on a pad of ruled paper.  
The boxes for letters such as `g'
extend below the baseline; the boxes for letters such as `h' don't. 
The height of a box is the distance that the box extends above its
baseline, while its depth is the distance that it extends below its
baseline. \bix^^{reference point}
The \minref{reference point}
of a box is the place where its baseline intersects its left edge.

{\tighten
\TeX\ builds an hbox $H$ from a horizontal list by assuming
a reference point for $H$ and then appending the items in the list to $H$
one by one from left to right.
Each box in the list is placed so that its baseline coincides with the
baseline of $H$\kern-2pt,
i.e., the component boxes are lined up horizontally.%
\footnote{If a box is moved up or down with ^|\raise| or 
^|\lower|, \TeX\ uses its reference point before the move when
placing it.}
The height of $H$ is the
height of the tallest box in the list, and the depth of $H$ is the depth
of the deepest box in the list.
The width of $H$ is the sum of the
widths of all the items in the list.
If any of these items are \refterm{glue} and \TeX\ needs to stretch or shrink
the glue,
the width of $H$ will be larger or smaller accordingly.
See \knuth{page~77} for the~details.
\par}

Similarly, \TeX\ builds a vbox $V$ from a vertical list by assuming a
temporary reference point for $V$ and then appending the items in the
list to $V$ one by one from top to bottom.  Each box in the list is
placed so that its reference point is lined up vertically with the
reference point of \Vperiod.\footnote{If a box is moved left or right with
^|\moveleft| or ^|\moveright|, \TeX\ uses its reference point before the
move when placing it.} As each box other than the first one is added to
\Vcomma, \TeX\ puts \minref{interline glue} just above it.  (This
^{interline glue} has no analogue for hboxes.)  The width of $V$ is the
width of the widest box in the list, and the vertical extent (height
plus depth) of $V$ is the sum of the vertical extents of all the
items in the list.

\bix^^|\vbox|
\bix^^|\vtop|
The difference between |\vbox| and |\vtop| is in how they partition
the vertical extent of $V$ into a height and a depth.
Choosing the reference point of $V$ determines that partition.
\ulist
\li For |\vbox|, \TeX\ places the reference point on a horizontal line
with the reference point of the last component box 
or rule of \Vcomma, except
that if the last box (or rule) is followed by glue or a kern, \TeX\ places the
reference point at the very bottom of \Vperiod.%
\footnote{The depth is limited by
the parameter ^|\boxmaxdepth| \ctsref{\boxmaxdepth}.}

\li For |\vtop|, \TeX\ places the reference point on a horizontal line
with the reference point of the first component box or rule of \Vcomma,
except that if the first box (or rule)
is preceded by glue or a kern, \TeX\ places
the reference point at the very top of \Vperiod.

\endulist
\noindent
Roughly speaking, then, |\vbox| puts the reference point near the bottom
of the vbox and |\vtop| puts it near the top.
When you want to align a
row of vboxes so that their tops line up horizontally,
you should usually use |\vtop| rather than |\vbox|. 
See \knuth{pages~78 and 80--81} for the
details of how \TeX\ builds vboxes.
\eix^^|\vbox|
\eix^^|\vtop|
\eix^^{reference point}

You have quite a lot of freedom in constructing boxes.  The typeset
material in a box can extend beyond the boundaries of the box as it does
for some letters (mostly italic or slanted ones).  The component boxes
of a larger box can overlap.  A box can have negative width, depth, or
height, though boxes like that are not often needed.

You can save a box in a box \refterm{register} and retrieve it later.
Before using a box register,
^^{box registers}
you should reserve it and give it a name
with the ^|\newbox| command \ctsref{\@newbox}.  See 
\conceptcit{register} for more information about box
registers.
\endconcept


\conceptindex{category codes}
\concept {category code}

The \defterm{category code} of a \refterm{character} determines that
character's role in \TeX.
^^{characters//category code of}
For instance, \TeX\ assigns a certain role to
letters, another to space characters, and so forth.  \TeX\ attaches a
code to each character that it reads.  When \TeX\ reads the
letter `|r|', for example, it ordinarily
attaches the category code $11$ (letter)
to it. For simple \TeX\ applications you won't need to worry about
category codes, but they become important when you are trying to achieve
special effects.

Category codes apply only to characters that \TeX\ reads from input
files.  Once a character has gotten past \TeX's ^{gullet} 
\seeconcept{\anatomy} and been interpreted, its category code no
longer matters.  A character that you produce with the ^|\char| command
\ctsref{\char} does not have a category code because |\char|
is an instruction to \TeX\ to produce a certain character in a certain
\refterm{font}.  For instance, the ^{\ascii} code for `|\|' 
(the usual escape character) is $92$.  If
you type `|\char92 grok|', it is \emph{not} equivalent to |\grok|.
Instead it tells \TeX\ to
typeset `$c$\kern.075em grok', where $c$ is the character in position $92$
of the code table for the current font.

You can use the ^|\catcode| command \ctsref{\catcode} to reassign the
category code of any character.  By changing category codes you can
change the roles of various characters.  For instance, if you type
`|\catcode`\@ = 11|', the category code of the at sign (|@|) will be set
to ``letter''.  You then can use `|@|' in the name of a control
sequence.

Here is a list of the category codes defined by \TeX,
(see \xref{twocarets} for an explanation of
the |^^| notation),
together with the characters in each category (as assigned
by \TeX\ and \refterm{\plainTeX}):

\xrdef{catcodes}
\vskip\abovedisplayskip
%k \vskip 0pt plus 2pt % to fix bad page break
{%k \interlinepenalty = 10000
\halign{\indent\hfil\strut#&\qquad#\hfil\cr
\it Code&\it Meaning\cr
\noalign{\vskip\tinyskipamount}
0&Escape character \quad |\| ^^{escape character//category code of}
   {\recat!ttidxref[\//category code of]]
   \cr
1&Beginning of group \quad |{| ^^{groups}
   {\recat!ttidxref[{//category code of]]
   \cr
2&End of group   \quad |}|
   {\recat!ttidxref[}//category code of]]
   \cr
3&Math shift   \quad |$| ^^{math shift}
   {\recat!ttidxref[$//category code of]]
   \cr
4&Alignment tab   \quad |&| ^^{tabs} ^^{alignments//tab character for}
   \ttidxref{&//category code of} \cr
5&End of line   \quad |^^M| \tequiv \ascii\ \asciichar{return}
   ^^{end of line} \ttidxref{^^M//category code of}\cr
6&Macro parameter   \quad |#|
   ^^{macros//parameters of}
   ^^{parameters//indicated by \b\tt\#\e}
   \ttidxref{#//category code of} \cr
7&Superscript   \quad |^| and |^^K| ^^{superscripts}
   \ttidxref{^^K}
   \ttidxref{^//category code of} \cr
8&Subscript   \quad |_| and |^^A| ^^{subscripts}
   \ttidxref{^^A}
   \ttidxref{_//category code of} \cr
9&Ignored character  \quad |^^@| \tequiv \ascii\ \asciichar{null}
  ^^{ignored characters} \indexchar ^^@ \cr
10&Space  \quad \visiblespace\ and |^^I| \tequiv \ascii\ 
  \asciichar{horizontal\ tab}
  ^^{horizontal tab}
  ^^{space characters//category code of} \indexchar ^^I
  {\recat!ttidxref[ ]]
  \cr
11&Letter  \quad |A| \dots |Z| and |a| \dots |z| ^^{letter}\cr
12&Other character \quad (everything not listed above or below) 
  ^^{other characters}\cr
13&Active character  \quad |~| and |^^L| \tequiv\ascii\ \asciichar{form\ feed} 
   ^^{active characters} ^^{form feed} \indexchar ~ \indexchar ^^L \cr
14&Comment character  \quad |%| ^^{comments}
   {\recat!ttidxref[%//category code of]]
   \cr
15&Invalid character  \quad |^^?| \tequiv \ascii\ \asciichar{delete}
  ^^{invalid character} \indexchar ^^? \cr
}}
\vskip\belowdisplayskip
%k \vskip 0pt plus 2pt % to fix bad page break

\noindent Except for categories $11$--$13$,
all the characters in a particular category produce the same effect.
\margin{Misleading material removed.}
For instance, suppose
that you type:
\csdisplay
\catcode`\[ = 1 \catcode`\] = 2
|
Then the left and right bracket characters become
beginning-of-group and end-of-group characters equivalent to
the left and right brace characters.  With these definitions `|[a b]|'
is a valid group, and so are \hbox{`|[a b}|'} and~\hbox{`|{a b]|'}.

The characters in categories $11$ (letter) and $12$ 
(other character) act as \refterm{commands:command}
that mean
``typeset the character with this code from the current font''.
The only distinction between letters and ``other'' characters is
that letters can appear in \refterm{control word}s but
``other'' characters~can't.

A character in category $13$ (active) acts like a control sequence
all by itself.  \TeX\ complains if it encounters an active character that
doesn't have a definition associated with it.
^^{active characters}

If \TeX\ encounters an ^{invalid character} (category $15$) 
in your input, it will complain about it. 

The `|^^K|' and `|^^A|' characters have been included in categories 
$8$ (subscript) and $9$ (superscript), even though these meanings
don't follow the standard \refterm{\ascii} interpretation.
That's because some keyboards, notably some at Stanford
University where \TeX\ originated,
have down arrow and up arrow keys that generate these characters.
\ttidxref{^^A}
\ttidxref{^^K}

There's a subtle point about the way \TeX\ assigns category codes that
can trip you up if you're not aware of it.  \TeX\ sometimes needs to
look at a character twice as it does its initial scan: first to find the
end of some preceding construct, e.g., a control sequence, and later to
turn that character into a token.  \TeX\ doesn't assign the category
code until its \emph{second} look at the character.  For example:

\csdisplay
\def\foo{\catcode`\$ = 11 }% Make $ be a letter.
\foo$ % Produces a `$'.
\foo$ % Undefined control sequence `\foo$'.
|
\noindent
This bit of \TeX\ code produces `\$' in the typeset output.  When
\TeX\ first sees the `|$|' on the second line,
it's looking for the end of a control sequence name.  Since
the `|$|' isn't yet a letter, it marks the end of `|\foo|'.  Next,
\TeX\ expands the `|\foo|' macro and changes the category code of `|$|'
to $11$ (letter).  Then \TeX\ reads the `|$|' ``for real''.  Since 
`|$|' is now a letter, \TeX\ produces a box
containing the `|$|' character in the current font.
When \TeX\ sees the third line, it treats `|$|' as a letter and thus
considers it to be part of the control sequence name.
As a result it complains about an undefined control sequence |\foo$|.
 
\TeX\ behaves this way even when the terminating character is an
end of line.  For example, suppose that the macro |\fum| activates the
end-of-line character.  Then if |\fum| appears on a line $\ell$ by
itself, \TeX\ will first interpret the end of line of $\ell$ as 
the end of the |\fum| control sequence and then will \emph{reinterpret}
the end of line of $\ell$ as an active character.
\endconcept


\conceptindex{characters}
\concept character

{\tighten
\TeX\ works with \defterm{characters} in two contexts:
as input characters, which it reads, and as output characters,
which it typesets.
\TeX\ transforms most input characters
into the output characters that depict them.
For example, it normally
transforms the input letter `|h|' into the letter `h' typeset in the current
font.
That is not the case, however, for an input character such as `|$|' that has a
special meaning.
\par}

\TeX\ gets its input characters by reading them from input files (or from your
terminal) and by expanding \refterm{macros:macro}.  These are the
\emph{only} ways that \TeX\ can acquire an input character.
Each input character has a code number corresponding to its position in the
\refterm{\ascii} code table.  ^^{\ascii}
For instance, the letter `|T|' has \ascii\ code~$84$.

When \TeX\ reads
a character, it attaches a \refterm{category code}
^^{category codes//attached during input}
to it.  The category code affects how \TeX\ interprets the
character once it has been read in.  \TeX\ determines
(and remembers) the category codes of the characters in a macro when it
reads the macro's definition.  As \TeX\ reads characters with its eyes
\seeconcept{\anatomy} it does some ``filtering'',
such as condensing
sequences of spaces to a single space.  See \knuth{pages~46--48} for the
details of this filtering.

The \ascii\
``^{control characters}'' have codes $0$--$31$ and $127$--$255$.
They either don't
show up or cause strange behavior on most terminals if you try to
display them.  Nonetheless they are sometimes needed in \TeX\ input,
so \TeX\ has a special notation for them.
\xrdef{twocarets}
If you type `|^^|$c$', where $c$ is any character, you get the character
whose \ascii\ code is either $64$ greater or $64$ less than $c$'s
\ascii\ code.  The largest acceptable code value using this notation
is $127$, so the notation is unambiguous.
Three particularly common instances of this
notation are `|^^M|' (the \ascii\ \asciichar{return} character),
`|^^J|' (the \ascii\ \asciichar{line\ feed} character) and `|^^I|'
(the \ascii\ \asciichar{horizontal\ tab} character).
\ttidxref{^^M}\ttidxref{^^J}\ttidxref{^^I}

{\tighten
\TeX\ also has another notation for indicating \ascii\ code values
that works for all character codes from $0$ to $255$.
\xrdef{hexchars}
If you type `|^^|$xy$', where $x$
and $y$ are any of the ^{hexadecimal digit}s `|0123456789abcdef|',
you get the single character with the specified code.
(Lowercase letters are required here.)
\TeX\ opts for the ``hexadecimal digits''
interpretation whenever it has a choice, so you must not follow a character
like `|^^a|' with a lowercase hexadecimal digit---if you do, you'll get the
wrong interpretation.
If you need to use this
notation you'll find it handy to have a table of \ascii\ codes.
\par}

An output character is a character to be typeset.
A command for producing an output character has the meaning
``Typeset
character number $n$ from the current \refterm{font}'',
where $n$ is determined by the command.
\TeX\ produces your typeset document by combining such characters
with
other typographical \hbox{elements} in boxes, and arranging them 
on the page.

An input character whose category code is $11$ (^{letter}) or $12$ (other)
^^{other characters}
acts as a command to produce the corresponding output character.  In
addition you can get \TeX\ to produce character $n$ by issuing the
command `|\char |$n$' \ctsref{\char}, ^^|\char| where $n$ is a
\refterm{number} between $0$ and $255$.  The commands `|h|',
|\char`h|, and |\char104| all have the same effect.  ($104$ is the
\ascii\ code for `h'.)

\endconcept


\concept class

The \defterm{class} of a \refterm{character} specifies that character's
role in math formulas.  The class of a character is encoded in its
\refterm{mathcode}.  ^^{mathcodes//class encoded in} For example, the
equals sign `|=|' has class $3$ (Relation).  \TeX\ uses its knowledge
of character classes to decide how much space to put between different
components of a math formula.  \margin{clarifying material added} For
example, here's a math formula shown first as \TeX\ normally prints it
and then with the class of each character randomly changed:
$$\strut a+(b-a)=a \qquad
   \mathopen{a}\mathord{+}\mathrel{(}\mathclose{b}\mathclose{-}
   \mathop{a}\mathopen{)}\mathord{=}\mathopen{a}$$

See \xrefpg\mathord\ of this book for a list of the classes and
\knuth{page~154} for their meanings.

\endconcept


\conceptindex{commands}
\concept command

A \defterm{command} instructs \TeX\ to carry out a certain action.
Every \refterm{token} that reaches \TeX's stomach \seeconcept{\anatomy}
acts as a command, except for those that are parts of arguments to
other commands (see below).
^^{tokens//as commands}
A command can be invoked by a
\refterm{control sequence}, by an \refterm{active character}, or by an
ordinary character.  It might seem odd that \TeX\ treats an ordinary
character as a command, but in fact that's what it does:
when \TeX\ sees 
an ordinary character
it constructs a \refterm{box} containing that character typeset in
the current font.

A command can have arguments.
The arguments of a command are single tokens or
groups of tokens that complete the description of what
the command is supposed to do.
For example, the command `|\vskip 1in|' tells \TeX\ to skip
$1$ inch vertically.  It has an argument `|1in|',
which consists of three tokens.
The description of what |\vskip| is supposed to do would be incomplete
without specifying how far it is supposed to skip.
The tokens in the arguments to a command are not themselves considered
to be commands.

Some examples of different kinds of \TeX\ commands are: 
\ulist\compact
\li Ordinary characters, such as `|W|', which instructs \TeX\
to produce a box containing a typeset `W'
\li Font-setting commands,
such as |\bf|, which begins boldface type
\li Accents, such as |\`|, which produces a grave accent as in `\`e'
\li Special symbols and ligatures, such as |\P| (\P) and |\ae| (\ae)
\li Parameters, such as |\parskip|, the amount of glue that
\TeX\ puts between paragraphs
\li Math symbols, such as |\alpha| ($\alpha$) and |\in| ($\in$)
\li Math operators, such as |\over|, which produces a fraction
\endulist
\endconcept


\conceptindex{conditional tests}
\concept {conditional test}

A \defterm{conditional test} is a command that tests whether or not a certain
condition is true and 
causes \TeX\ either to expand or to skip some text, depending on
the outcome.
The general form of a conditional test is either:
\display{
{\tt \\if}$\alpha$\<true text>{\tt \\else}\<false text>{\tt \\fi}}
^^|\else|^^|\fi|
\noindent or:\hfil\
\display{
{\tt \\if}$\alpha$\<true text>{\tt \\fi}}
\noindent where $\alpha$ specifies the particular test.
For example, |\ifvmode| tests the condition that \TeX\
is currently in a \refterm{vertical mode}.
If the condition is true, \TeX\ expands \<true text>.
If the condition is false, \TeX\ expands \<false text> (if it's present).
Conditional tests are interpreted in \TeX's gullet
\seeconcept{\anatomy}, so any expandable \minref{token}s in
the interpreted text are expanded after the test has been resolved.
The
various conditional tests are explained in \headcit{Conditional tests}%
{conds}.

\endconcept


\conceptindex{control sequences}
\concept{control sequence}

A \defterm{control sequence} is a name for a \TeX\ \refterm{command}.
A control sequence always starts with an ^{escape character}, usually
a backslash (|\|).
\indexchar \
A control sequence takes one of two forms:

\ulist

\li A \refterm{control word} is a control sequence consisting of an
\refterm{escape character} followed by one or more letters.
^^{control words}
The control
word ends when \TeX\ sees a nonletter.  For instance, when \TeX\ reads
`\hbox{|\hfill!visiblespace,!visiblespace!.the|}', it sees six 
\refterm{tokens:token}:
the control sequence `|\hfill|', comma, space, `|t|', `|h|', `|e|'.  The
space after `|\hfill|' ends the control sequence and
is absorbed by \TeX\ when it scans the control sequence.
(For the text `|\hfill,!visiblespace!.the|', on the other hand,
the comma both ends the control sequence and counts as a character in its
own right.)

\li A \refterm{control symbol}
^^{control symbols}
is a control sequence consisting of an
^{escape character} followed by any character other than a letter---%
even a space or an end of line.
A control symbol is self-delimited, i.e., \TeX\ knows where it ends without
having to look at what character comes after it.
The character after a control symbol is never absorbed by
the control symbol.
\endulist
\noindent See \xrefpg{spaces} for more information about spaces after control
sequences. 

\TeX\ provides a great many predefined control sequences.  The
\refterm{primitive} control sequences are built into the \TeX\ computer
program and thus are available in all forms of \TeX.
^^{primitive//control sequence}
Other
predefined control sequences are provided by \refterm{\plainTeX}, the
form of \TeX\ described in this book.

You can augment the predefined control sequences with ones of your own,
using commands such as ^|\def| and ^|\let| to define them.
\chapterref{eplain} of this book contains a
collection of control sequence definitions that you may find
useful.  In addition, your computing facility may 
be able to provide a collection of
locally developed \TeX\ macros.
\endconcept


\conceptindex{control symbols}
\concept{control symbol}

A \defterm{control symbol} is a \refterm{control sequence} that consists
of an \refterm{escape character} followed by any character other than a
letter---even a space or end of line.
^^{escape character}
\endconcept


\conceptindex{control words} 
\concept{control word} 

A \defterm{control word} is a \refterm{control sequence} that consists
of an \refterm{escape character} followed by one or more
letters.\footnote{A ``letter'' here has the strict meaning of a
character with category code $11$.}
\TeX\
ignores any spaces or ends-of-line that follow a control word, except to
note that they end the control word.
^^{escape character}
\endconcept



\concept {decimal constant}

See \conceptcit{number}.
\endconcept

\conceptindex{delimiters}
\concept delimiter

A \defterm{delimiter} is a character
that is intended to be used as
a visible boundary of a math formula.
The essential property of a delimiter is that \TeX\ can adjust
its size according
to the vertical size (\refterm{height} plus \refterm{depth})
of the subformula.
However, \TeX\ performs the adjustment only if the delimiter
appears in a ``delimiter context'', namely, as an argument to 
one of the commands ^|\left|,
^|\right|,
|\over!-with!-delims|,
|\atop!-with!-delims|,
or |\above!-with!-delims|
^^|\overwithdelims|
^^|\atopwithdelims|
^^|abovewithdelims|
\margin{Footnote deleted}
(see \pp\xrefn{\overwithdelims},~\xrefn{\left}).
The delimiter contexts also include any \refterm{argument}
to a \refterm{macro} that uses the argument in a delimiter context.

For example, the left and right
parentheses are delimiters.
If you use ^{parentheses} in a delimiter context
around a formula, \TeX\ makes the parentheses big
enough to enclose the \refterm{box} that contains the formula (as long as the
\refterm{fonts:font} you're using have big enough parentheses).
For example:
\csdisplay
$$ \left( a \over b \right) $$
|
yields:
\centereddisplays $$\left (a \over b \right ) $$
Here \TeX\ has made the parentheses big enough to accommodate the fraction.
But if you write, instead:
\csdisplay
$$({a \over b})$$
|
you'll get:
$$({a \over b})$$
Since the parentheses aren't in a delimiter context,
they are \emph{not} enlarged.  

Delimiters come in pairs:
an opening delimiter at the left of the subformula
and a closing delimiter at its right.
You can explicitly choose a larger height for a
delimiter with the commands ^|\bigl|, ^|\bigr|, and their
relatives \ctsref{\bigl}.\footnote
{\PlainTeX\ defines the various |\big| commands by using |\left| and |\right|
to provide a delimiter context.  It sets the size by
constructing an empty formula with the desired height.}
For instance, in order to get the
displayed formula:
$$\bigl(f(x) - x \bigr) \bigl(f(y) - y \bigr)$$

\noindent in which the outer parentheses are a little bigger than the inner
ones, you should write:

\csdisplay
$$\bigl( f(x) - x \bigr) \bigl( f(y) - y \bigr)$$
|

The $22$ \plainTeX\ delimiters, shown at their normal size, are:
\display{%
$( \>) \>[ \>] \>\{ \>\}
\>\lfloor \>\rfloor \>\lceil \>\rceil
\>\langle \>\rangle \>/ \>\backslash
\>\vert \>\Vert
\>\uparrow \>\downarrow \>\updownarrow
\>\Uparrow \>\Downarrow \>\Updownarrow$}
^^|)| ^^|)| ^^|[| ^^|]| ^^|\lbrack| ^^|\rbrack|
^^|\{| ^^|\}| ^^|\lbrace| ^^|\rbrace|
^^|\lfloor| ^^|\rfloor|  ^^|\lceil|  ^^|\rceil|
^^|\langle|  ^^|\rangle|  ^^|/|  ^^|\backslash|
^^|\vert|  ^^|\Vert|
^^|\uparrow|  ^^|\downarrow|  ^^|\updownarrow|
^^|\Uparrow|  ^^|\Downarrow|  ^^|\Updownarrow|
\noindent
Here they are at the largest size provided explicitly by \plainTeX\
 (the |\Biggl|, |\Biggr|, etc., versions):
\nobreak\vskip .5\abovedisplayskip
\display{%
$\Biggl( \>\Biggr) \>\Biggl[ \>\Biggr]
\>\Biggl\{ \>\Biggr\} \>\Biggl\lfloor \>\Biggr\rfloor
\>\Biggl\lceil \>\Biggr\rceil
\>\Biggl\langle \>\Biggr\rangle
\>\Biggm/ \>\Biggm\backslash
\>\Biggm\vert \>\Biggm\Vert
\>\Biggm\uparrow \>\Biggm\downarrow \>\Biggm\updownarrow
\>\Biggm\Uparrow \>\Biggm\Downarrow \>\Biggm\Updownarrow$}
\vskip .5\belowdisplayskip
\noindent
The delimiters (except for `|(|', `|)|', and
`|/|')
are among the symbols listed on
pages~\xrefn{\lbrace}--\xrefn{\Uparrow}.
They are listed in one place on \knuth{page~146}.

A delimiter can belong to any class.
^^{class//of a delimiter}
For a delimiter that you enlarge with
|\bigl|, |\bigr|, etc., the class is determined by the command:
``opener'' for |l|-commands, ``closer'' for |r|-commands, 
``relation'' for |m|-commands, and ``ordinary symbol'' for |g|-commands,
e.g., |\Big|.

You can obtain a delimiter in two different ways:
\olist
\li You can make a character be a delimiter by assigning it a
nonnegative delimiter code
\bix^^{delimiter codes}
(see below) with the ^|\delcode| command (\xref\delcode).
Thereafter the character acts as a delimiter whenever you use it in a
delimiter context.\footnote{%
It's possible to use a character with a nonnegative delimiter code in
a context where it isn't a delimiter. In this case \TeX\ doesn't perform the
search; instead it just uses the character in the ordinary way
(see \knuth{page~156}).}
\li You can produce a delimiter explicitly with the ^|\delimiter| command
(\xref\delimiter), in analogy to the way that you can produce an ordinary
character with the |\char| command or a math character with the |\mathchar|
command.
The |\delimiter| command uses the same delimiter codes that are used in a
|\delcode| table entry, but with an extra digit in front to indicate a
class.
It's rare to use |\delimiter| outside of a macro definition.
\endolist

A delimiter code tells
\TeX\ how to search for an appropriate output character to represent
a delimiter.
The rules for this search are rather complicated
(see \knuth{pages~156 and 442}).
A complete understanding of these rules requires knowing
about the organization of font ^{metrics file}s, a topic that is not just beyond
the scope of this book but beyond the scope of \texbook\ as well.

In essence the search works like this.  The delimiter code specifies a
``small'' output character and a ``large'' output character by
providing a \refterm{font} position and a font \refterm{family} for each
(see \xref\delcode).
Using this information, \TeX\ can find (or construct)
larger and larger versions of the delimiter.  \TeX\ first tries 
different sizes (from small to large) 
of the ``small'' character in the ``small'' font
and then
different sizes (also from small to large)
of the ``large'' character in the ``large'' font,
seeking one whose height plus depth is sufficiently large.
If none of the characters it finds are large
enough, it uses the largest one that it finds.
It's possible that
the small character, the large character, or both have been left unspecified
(indicated by a zero in the appropriate part of the delimiter code).
If only one character
has been specified, \TeX\ uses that one. If neither has been specified, 
it replaces the delimiter by a space of width ^|\nulldelimiterspace|.
\eix^^{delimiter codes}

\endconcept


\concept demerits

\TeX\ uses \refterm{demerits} as a measure of how undesirable a line is
when it's breaking a paragraph into lines \seeconcept{line break}.
^^{line breaks//demerits for}
The demerits of a line are affected both by the \refterm{badness} of the line
and by \refterm{penalties:penalty} associated with the line.
^^{badness}
\TeX's goal in choosing a particular arrangement of lines is to minimize the
total demerits for the paragraph, which it computes by adding up the demerits
for the individual lines.
See \knuth{pages~97--98} for the details of how \TeX\
breaks a paragraph into lines.  
\TeX\ does not use demerits when it's choosing page breaks; instead, it uses
a similar measure known as the ``cost'' of a particular page break.
\endconcept

\concept depth

^^{boxes//depth of}
The \defterm{depth} of a \refterm{box} is the distance that the box extends
below its \refterm{baseline}. 
\endconcept


\conceptindex{dimensions}
\concept dimension

A \defterm{dimension} specifies a distance, that is, a linear measure of
space.  You use dimensions to specify sizes of things, such as the length
of a line.  Printers in English-speaking countries traditionally measure
distance in points and picas, while printers in continental Europe
traditionally measure distance in did\^ot points and ciceros.  You can
use these units or others, such as inches, that may be more
familiar to you.  The font-independent
^{units of measure} that \TeX\ understands are:

\xrdef{dimdefs}
\nobreak\vskip\abovedisplayskip
\halign{\indent\hfil\tt #\qquad&#\hfil\cr
pt&^{point} (72.27 points = 1 inch)\cr
pc&^{pica} (1 pica = 12 points)\cr
bp&big point (72 big points = 1 inch)\cr
in&^{inch}\cr
cm&^{centimeter} (2.54 centimeters = 1 inch)\cr
mm&^{millimeter} (10 millimeters = 1 centimeter)\cr
dd&^{\didotpt} (1157 {\didotpt}s = 1238 points)\cr
cc&^{cicero} (1 cicero = 12 {\didotpt}s)\cr
sp&^{scaled point} (65536 scaled points = 1 point)\cr
}
\vskip\belowdisplayskip

Two additional units of measure are associated with every font: `^|ex|',
a vertical measure usually about the height of the letter `x'
in the font, and `^|em|', a
horizontal measure usually equal to the point size of the font and
about the width of the letter `M' in the font. Finally,
\TeX\ provides three ``infinite'' units of measure: `^|fil|', `^|fill|', and
`^|filll|', in increasing order of~strength.

A dimension is written as a ^{factor}, i.e, a multiplier, 
followed by a unit of measure.
^^{units of measure}
The factor can be either a whole \refterm{number} or
a \refterm{decimal constant} containing a decimal point
or decimal comma.  
The factor can be preceded by a plus or minus sign, so a dimension
can be positive or negative.
^^{dimensions//negative}
The unit of measure must be there, even if the number is
zero.  Spaces between the number and the unit of measure are permitted
but not required.  You'll find a precise definition of a
dimension on \knuth{page~270}.  Here are some examples of dimensions:

\csdisplay
5.9in    0pt    -2,5 pc    2fil
|
The last of these represents a first-order infinite distance.

An infinite distance outweighs any finite distance or any weaker infinite
distance.  If you add |10in| to |.001fil|, you get |.001fil|; if you add
|2fil| to |-1fill| you get |-1fill|; and so forth. 
\TeX\ accepts infinite distances
only when you are specifying the \refterm{stretch} and \refterm{shrink}
of \refterm{glue}.

\TeX\ multiplies all dimensions in your document by a
\refterm{magnification} factor $f/1000$,
where $f$ is the value of the ^|\mag| parameter.
^^{magnification}
Since the default value of
|\mag| is $1000$, the normal case is that your document is
typeset just as specified.  You can specify a dimension as it will be
measured in the final document independent of magnification by putting
`|true|' in front of the unit.  For instance, `|\kern 8 true pt|'
produces a kern of $8$ points whatever the magnification.
\endconcept


\concept {display math}

The term \defterm{display math} refers to a math formula that \TeX\
places on a line by itself with extra space above and below 
so as to set it off from the surrounding text.
A display math formula is enclosed by `|$$|'s.
\ttidxref{$$}
\TeX\ reads display math in display math \refterm{mode}.
\endconcept


\concept{escape character}

An \defterm{escape character} introduces a control sequence.  The escape
character in \refterm{\plainTeX} is the backslash (|\|).
\indexchar \
You can change the escape character from $c_1$ to $c_2$
by reassigning the category codes of $c_1$ and $c_2$
with the ^|\catcode| command \ctsref{\catcode}.
You can also define additional escape characters similarly.
If you want to typeset material containing literal escape characters, you must
either 
(a) define a control sequence that stands for the printed escape character or
(b) temporarily
disable the escape character by changing its category code, using the
method shown on \xrefpg{verbatim}.  The definition:

\csdisplay
\def\\{$\backslash$}
|
is one way of creating a control sequence that stands for `$\backslash$'
(a backslash typeset in a math font).

You can use the ^|\escapechar| parameter \ctsref{\escapechar} to specify
how the escape character is represented in synthesized control sequences,
e.g., those created by |\string| and |\message|.


\endconcept


\concept family

A \defterm{family} is a group of three related \refterm{fonts:font} used
when \TeX\ is in \refterm{math mode}.
^^{fonts//families of}
Outside of math mode, families
have no effect.  The three fonts in a family are used for normal symbols
(\refterm{text size}), subscripts and superscripts (\refterm{script
size}), and sub-subscripts, super-superscripts, etc.\
(\refterm{scriptscript size}).
^^{text size}
^^{script size}
^^{scriptscript size}
For example, the numeral `|2|' set in
these three fonts would give you `$2$', `$\scriptstyle 2$', and
`$\scriptscriptstyle 2$' (in \plainTeX).
Ordinarily you would set up the
three fonts in a family as different point sizes of the same typeface,
but nothing prevents you from using different typefaces for the three
fonts as well or using the same font twice in a family.

{\tighten
\TeX\ provides for up to sixteen families, numbered $0$--$15$.  For
example, family $0$ in \refterm{\plainTeX} consists of $10$-point roman
for text, $7$-point roman for script, and $5$-point roman for
scriptscript.
^^{\plainTeX//font families in}
\PlainTeX\ also defines family $1$ to consist of math
italic fonts and reserves families $2$ and $3$ for ^{special symbols} and
^{math extensions} respectively.\footnote{Families $2$ and $3$ are special
in that their font metric files must include parameters for math
spacing.} If you need to define a family for yourself, you should use
the ^|\newfam| command \ctsref{\@newfam} to get the number of a family that
isn't in use, and the ^|\textfont|, ^|\scriptfont|,
and ^|\scriptscriptfont| commands \ctsref{\scriptscriptfont}
to assign fonts to that family.
\par}

\endconcept


\conceptindex{files}
\concept file

A \defterm{file} is a stream of information that \TeX\ interprets or
creates.  Files are managed by the ^{operating system} that supervises your
\TeX\ run.  \TeX\ deals with files in four different contexts:
\olist
\li A ``^{source file}'' is one that \TeX\ reads with its ``eyes''
\seeconcept{\anatomy} and interprets according to its ordinary rules.
Your primary input file---the one you specify after `|**|' or
on the command line when
you invoke \TeX---is a source file, and so is any file that you call for
with an ^|\input| command \ctsref \input.

\li A ``^{result file}'' is one that contains the results of 
running \TeX.  A \TeX\ run creates two result files: the
\dvifile\ and the log file.
^^{\dvifile//as a result file}
^^{log file//as a result file}
The \dvifile\ contains the information needed to print your document;
the
log file contains a record of what happened during the run, including any
error messages that \TeX\ generated.
If your primary source file is named
|screed.tex|, your \dvifile\ and log file will be named |screed.dvi|
and |screed.log|.\footnote{This is the usual convention, but
particular implementations of \TeX\ are free to change it.}

\li To read from a file with the ^|\read|
command \ctsref{\read} you need to associate the file with an input stream.
^^{input streams//reading with \b\tt\\read\e}
You can have up to $16$ input streams active
at once, numbered $0$--$15$.  
The |\read| command reads a single line and makes it the value of a
designated \refterm{control sequence}, so reading with 
|\read| is very different from reading with ^|\input| (which brings in an
entire file).
\TeX\ takes any input stream number not between
$0$ and $15$ to refer to the terminal,
so `|\read16|', say, reads the next line that you type at the terminal.

\li To write to a file with the |\write|
command \ctsref \write\ you need to associate the file
with an output stream.
^^|\write//output stream for|
^^{output streams}
You can have up to $16$ output streams active
at once, numbered $0$--$15$.  
Input and output streams are independent.
Anything sent to an output stream with a negative number goes to the log
file; anything sent to an output stream with a number greater than $15$
goes both to the log file and to the terminal.
Thus `|\write16|', say, writes a line on the terminal and also sends
that line
to the log~file.

\endolist

You must open a stream file before you can use it.
An input stream file is opened with an ^|\openin|
command  \ctsref \openin\ and an output stream file is opened with an
^|\openout| command \ctsref\openout.
For tidiness
you should close a stream file when you're done with it, although
\TeX\ will do that at the end of the run if you don't.
The two commands for closing a stream file are ^|\closein| \ctsref\closein\
and ^|\closeout| \ctsref\closeout.
An advantage of closing a stream when
you're done with it is that you can then reuse the stream for a different file.
Doing this can be essential when you're reading a long sequence of files.

Although you can assign numbers yourself to input and output streams,
it's better to do it with the ^|\newread| and
^|\newwrite| \ctsref{\@newwrite} commands.
You can have more than one stream associated with a particular file,
but you'll get (probably undiagnosed) garbage unless all of the streams
are input streams.  Associating more than one stream with an input file
can be useful when you want to use the same input file for two different
purposes.

\TeX\ ordinarily defers the actions of opening, writing to, or closing
an output stream until it ships out a page with ^|\shipout|
(see \knuth{page~227}
for the details).  This behavior applies even to messages written to the
terminal with |\write|.  But you can get \TeX\ to perform an action
on an output stream immediately by preceding the action command with
^|\immediate| \ctsref\immediate.  For example:
\csdisplay
\immediate\write16{Do not pass GO!! Do not collect $200!!}
|
\endconcept


\conceptindex{file names}
\concept {file name}

A \defterm{file name} names a 
\refterm{file} that is known to the ^{operating system}
that in turn
supervises your \TeX\ run.  The syntax of a file name does \emph{not}
follow the usual rules of \TeX\ syntax, and in fact it is different
in different implementations of \TeX.
In particular, most \TeX\ implementations consider a file name to be
terminated by a blank or an end of line.  Thus \TeX\ is likely to
misinterpret `|{\input chapter2}|' 
by taking the right brace as part of the file name.
As a general rule, you should follow a file name by a blank or the
end of the line as in `|{\input chapter2!visiblespace}|'.

\endconcept


\eject
\conceptindex{fonts}
\concept font

A \defterm{font} in \TeX\ is a collection of up to $256$ output
characters, usually having the same typeface design, style (roman,
italic, bold, condensed, etc.),
and point size.\footnote{\PlainTeX\ uses a special
font for constructing ^{math symbols} in which the characters have
different sizes.  Other special fonts are often useful for applications
such as typesetting ^{logos}.} The ^{Computer Modern fonts} that
generally come with \TeX\ have only $128$ characters. The colophon on
the last page of this book describes the typefaces that we used to set
this book.

For instance, here is the alphabet in the Palatino Roman $10$ point font:
^^{Palatino fonts}
\vskip\abovedisplayskip{\narrower\tenpal
\noindent ABCDEFGHIJKLMNOPQRSTUVWXYZ\hfil\break
abcdefghijklmnopqrstuvwxyz\par
}\vskip\belowdisplayskip
\noindent
And here it is in the Computer Modern Bold Extended $12$
point font:
^^{Computer Modern fonts}
\vskip\abovedisplayskip{\narrower\font\twelvebf=cmbx12\twelvebf
\noindent ABCDEFGHIJKLMNOPQRSTUVWXYZ\hfil\break
abcdefghijklmnopqrstuvwxyz\par
}\vskip\belowdisplayskip
The characters in a font are numbered.
The numbering usually agrees with the ^{\ascii} numbering
for those characters that exist in the \ascii\ character set.
The code table for each font indicates what the character
with code $n$ looks like in that font.
Some fonts, such as the ones used for mathematical symbols, have no
letters at all in them.  You can produce a \refterm{box} containing the
character numbered $n$, typeset in the current font, by writing `|\char |$n$'
 \ctsref{\char}.

In order to use a font in your document,
you must first name it with a control sequence and load it.  Thereafter you
can select it by typing
that control sequence whenever you want to use it.
\PlainTeX\ provides a number of fonts that are already named and~loaded.

You name and load a font as a single operation, using a
command such as `|\font\twelvebf=cmbx12|'.  Here `|\twelvebf|' is the
control sequence that you use to name the font
and `|cmbx12|' identifies the font metrics file
|cmbx12.tfm| 
in your computer's file system.
You then can start to use the font by typing
`|\twelvebf|'.  After that, the font will be in effect until
either (a)~you select another font or (b)~you terminate the
\refterm{group}, if any, in which you started the
font.  For example, the input:

\csdisplay
{\twelvebf white rabbits like carrots}
|
will cause the |cmbx12| font to be in effect just for the
text `|white rabbits like carrots|'.

You can use \TeX\ with fonts other than
Computer Modern (look at the example on \xrefpg{palatino} and
at the page headers). 
The files for such fonts need to be
installed in your computer's file system in a place where \TeX\ can find
them.  \TeX\ and its companion programs generally need two files for each font:
one to give its metrics (|cmbx12.tfm|,
^^{\tfmfile}
for example) and another to
give the shape of the characters (|cmbx12.pk|, for example).
\TeX\ itself uses only the metrics
file.  Another program, the device driver,
^^{device drivers}
converts the \dvifile\
^^{\dvifile//converted by driver}
produced by \TeX\ to a form that your printer
or other output device can handle.  The driver
uses the shape file (if it exists).

The font metrics file contains the information that \TeX\ needs in
order to allocate space for each typeset character.
Thus it includes the size of each character, the ligatures and
kerns that pertain to sequences of adjacent characters, and so on.
What the metrics file
\emph{doesn't} include is any information about the shapes
of the characters in the font.

{\tighten
The shape (pixel) file \xrdef{shape}
^^{pixel file}^^{shape file}
may be in any of several
formats. The extension part of the name (the part after the dot)
tells the driver which format the shape file is in.  For example,
|cmbx12.pk| ^^{\pkfile} might be the shape file for font |cmbx12| in
packed format, while |cmbx12.gf| ^^{\gffile} might be the shape file
for font |cmbx12| in generic font format.
A shape file may not be needed for a font that's resident in your
output device.
\par}

\endconcept


\conceptindex{footers}
\concept footer

A \defterm{footer} is material that \TeX\ puts at the bottom of every page,
below the text of that page.
The default footer in \plainTeX\ is a centered page number.
Ordinarily a footer consists of a single line, which you can set by
assigning a token list to ^|\footline| \ctsref\footline.
See \xrefpg{bighead} for a method of producing multiline footers.

\endconcept

%k \vskip 0pt plus 2pt % to solve page break problem

\concept {format file}

{\tighten
A \defterm{format file} is a file that contains an image of
\TeX's memory in a form in which it can be reloaded quickly.
A format file can be created with the ^|\dump| command \ctsref\dump.
The image contains a complete record
of the definitions (of \refterm{fonts:font}, \refterm{macros:macro}, etc.)
that were present when the dump took place.
By using ^|virtex|, a special ``virgin'' form of \TeX,
you can then reload the format file at high speed and 
continue in the same state that \TeX\ was in at the time of the dump.
The advantage of a format file over an ordinary input
file containing the same information is that \TeX\ can load it much
faster.
\par}

Format files can only be created by ^|initex|, another special
form of \TeX\ intended just for that purpose.
Neither |virtex| nor |initex| has any
facilities other than the primitives built into the
\TeX\ program itself.

A ^{preloaded} form of \TeX\ is one that has a format file already 
loaded and is ready to accept user input.
The form of \TeX\ that's called |tex|
often has the \plainTeX\ definitions preloaded.
(\PlainTeX\ is ordinarily  available in two other forms as well:
as a format file and as a \TeX\ source file.
In some environments, |tex| is equivalent to calling |virtex|
and then loading |plain|.)
Creating preloaded forms of \TeX\ requires a special program;
it cannot be done using only the facilities of \TeX\ itself.

\endconcept

\concept global

A \defterm{global} definition is effective 
until the end of the
document or until it is overridden by another definition,
even when it occurs within a \refterm{group}.  
Thus a global definition is unaffected by group boundaries.
You can make any definition global by prefixing it with the |\global|
command \ctsref{\global} unless ^|\globaldefs| \ctsref\globaldefs{}
is negative.
^^|\global|

There's a special way of making a \refterm{macro} definition global.
^^{macros//global}
Normally you define a macro using either the |\def| command
or the |\edef| command \ctsref{\edef}.
^^|\edef//making global|
^^|\def//making global|
If you use |\gdef| or |\xdef|
instead of |\def| and |\edef| respectively, the macro definition will
be global.  That is, `^|\gdef|' is equivalent to `|\global\def|' and
`^|\xdef|' is equivalent to `|\global\edef|'.
\endconcept


\concept glue

\bix^^{stretch}
\bix^^{shrink}
\defterm{Glue} is blank space that can stretch or shrink. 
Glue gives \TeX\ the flexibility that it needs in order to produce
handsome
documents.  Glue comes in two flavors: horizontal glue and vertical glue.  
Horizontal glue occurs within \refterm{horizontal lists:horizontal list},
while vertical glue occurs within \refterm{vertical lists:vertical list}.
^^{horizontal lists}
^^{vertical lists}
You
can produce a glue item either implicitly, e.g., with an interword space, or
explicitly, e.g., with the ^|\hskip| command.
^^{spaces//interword}
\TeX\ itself produces many glue
items as it typesets your document.
We'll just describe horizontal glue---vertical glue is analogous.

When \TeX\ assembles a list of boxes and glue into a larger
unit,
^^{boxes//glue with}
it adjusts the size of the glue to meet the space requirements of the
larger unit.  For instance, \TeX\ ensures that the ^{right margin} of a page
is uniform by adjusting the horizontal glue within lines.
Similarly, it ensures that different pages have the
same ^{bottom margin}
by adjusting the glue between blocks of text such as paragraphs and
math displays
(where the change is least likely to be conspicuous).

A glue item has a natural space---the size it ``wants to be''.  Glue
also has two other attributes: its \refterm{stretch} and its
\refterm{shrink}.  You can produce a specific amount of horizontal glue
with the ^|\hskip| \refterm{command} \ctsref{\hskip}.  The command 
|\hskip 6pt plus 2pt minus 3pt|
produces a horizontal glue item whose natural
size is $6$ points, whose stretch is $2$ points, and whose shrink is
$3$ points.  Similarly, you can produce a specific amount of vertical
glue with the ^|\vskip| command \ctsref{\vskip}.

The best way to understand what stretch and shrink are about
is to see an example of glue at work.
Suppose you're constructing an \refterm{hbox} from three boxes and two glue
items, as in this picture:
\gluepicture 
   29 {\picbox 4 \gluebox 6 4 1 6 \picbox 5 \gluebox 10 8 3 10 \picbox 4 }
\noindent
The units of measurement here could be points, millimeters, or anything else.
If the hbox is allowed to assume its natural width, then each glue item in the
box also assumes its natural width.  The total width of the hbox is then the
sum of the widths of its parts, namely, $29$ units.

Next, suppose that the hbox is required to be wider than $29$ units, say
$35$ units.  This
could happen, for example, if the hbox is required to occupy an entire
line and the line width is $35$ units.
Since the boxes can't change their width, 
\TeX\ produces the necessary extra space by making the glue items wider.
The picture now looks like this:
\gluepicture 
   35 {\picbox 4 \gluebox 6 4 2 8 \picbox 5 \gluebox 10 8 6 14 \picbox 4 }
The glue items don't become wider equally; they became wider in proportion to
their stretch.  Since the second glue item 
has twice as much stretch as the first one, 
it gets wider by four units while the first glue item gets wider by only 
two units.
Glue can be stretched as far as necessary, although \TeX\ is
somewhat reluctant to
stretch it beyond the amount of stretch given in its definition.

Finally, suppose that the hbox is required to be narrower than $29$ units, say
$25$ units.  In this case \TeX\ makes the glue items narrower.
The picture looks like this:
\gluepicture 
   25 {\picbox 4 \gluebox 6 4 2 5 \picbox 5 \gluebox 10 8 6 7 \picbox 4 }
The glue items become narrower in proportion to their shrink.
The first glue item becomes narrower by one unit, while the second glue item
becomes narrower by three units.  Glue cannot shrink by a distance
less than the amount of shrink
given in its definition even though the distance it can stretch is
unlimited.  In this important sense the shrink and 
the stretch behave differently.

A good rule of thumb for glue is to set the natural size to the amount
of space that looks best, the stretch to the largest amount of space
that \TeX\ can add before the document starts to look bad, and the
shrink to the largest amount of space that \TeX\ can take away before
the document starts to look bad.  You may need to set the values by
experiment.

You can produce glue that is infinitely stretchable  by specifying
its stretch in units of `^|fil|', `^|fill|', or `^|filll|'.   Glue measured in
`|fill|' is infinitely more stretchable than glue measured in `|fil|', and
glue measured in `|filll|'  is infinitely more stretchable than glue measured
in `|fill|'.  You should rarely have any need for `|filll|' glue.  Glue whose
stretch is |2fil| has twice as much stretch as glue whose stretch is |1fil|,
and similarly for the other kinds of infinitely stretchable glue.

When \TeX\ is
apportioning extra space among glue items, the infinitely stretchable
ones, if there
are any, get all of it.  Infinitely stretchable glue is particularly useful for
setting text flush left, flush right, or centered:

\ulist\compact
\li To set text ^{flush left}, put infinitely stretchable
horizontal glue to the right of it.
That glue will consume all the 
extra space that's available on the line.
You can use the ^|\leftline| command \ctsref{\leftline} 
or the |\raggedright| command \ctsref{\raggedright} to do~this.
\li To set text ^{flush right}, put infinitely
stretchable horizontal glue to the left of it.
As before, that glue will consume all the extra space on the line.
You can use the ^|\rightline| command \ctsref{\rightline} to do~this.
\li To set ^{centered text}, put identical infinitely stretchable
horizontal glue items
on both sides of it.
These two glue items will divide all the extra space on the line
equally between them.
You can use the ^|\centerline| command \ctsref{\centerline} to do~this.
\endulist

You can also specify infinitely shrinkable glue
^^{glue//infinitely shrinkable}
in a similar way.  Infinitely shrinkable glue can act as negative space.
Note that |fil|, etc., can be used only 
to specify the stretch and shrink of glue---they can't be used to specify
its natural size.
\eix^^{stretch}
\eix^^{shrink}
\endconcept


\conceptindex{groups}
\concept group

A \defterm{group} is a part of your manuscript that \TeX\ treats as a unit.
You indicate a group by enclosing it in the braces
`|{|' and `|}|' (or any other characters with the appropriate
\refterm{category codes}).
^^|{//starting a group|
^^|}//ending a group|

The most important property of a group is that any nonglobal
definition or assignment that you make inside a group disappears when
the group ends.  For instance, if you write:

\csdisplay
Please don't pour {\it any} more tea into my hat.
|
the |\it| \refterm{control sequence} causes \TeX\ to set the word
`|any|' in italic type but does not affect the rest of the text.
As another example, if you use the |\hsize| parameter
\ctsref{\hsize} to change the line length within a group, the line length
reverts to its previous value once \TeX\ has gotten past the group.

Groups are also useful as a way of controlling spacing.  For instance, if you
write:

\csdisplay
\TeX for the Impatient and the Outpatient too.
|
\noindent
you'll get:
\display{%
\TeX for the Impatient and the Outpatient too.
}
\noindent
since the control sequence |\TeX| (which produces the \TeX\
logo) absorbs the following space. 
What you probably want is:
\display{%
{\TeX} for the Impatient and the Outpatient too.
}
\noindent
One way to get it is to enclose `|\TeX|' in a group:
\csdisplay
{\TeX} for the Impatient and the Outpatient too.
|
The right brace prevents the control sequence from absorbing the space.
\endconcept


\conceptindex{hboxes}
\concept hbox

An \defterm{hbox} (horizontal box) is a \refterm{box} that \TeX\
constructs by placing the items of a \refterm{horizontal list} one after
another, left to right.
^^{horizontal lists//hboxes formed from}
An hbox, taken as a unit, is neither
inherently horizontal nor inherently vertical, i.e., it can appear as an
item of either a horizontal list or a \refterm{vertical list}.  You can
construct an hbox with the |\hbox| command \ctsref{\hbox}.
\endconcept


\conceptindex{headers}
\concept header

A \defterm{header} is material that \TeX\ puts at the top of every page,
above the text of that page.
The header for a simple report
might consist of the title on the left side of
the page and the text ``Page $n$'' on the right side of the page.
Ordinarily a header consists of a single line, which you can set by
assigning a token list to ^|\headline| \ctsref\headline.
The default \plainTeX\ header is blank.
It's possible to produce multiline headers too; see \xrefpg{bighead} for
how to do it.
\endconcept


\concept height

The \defterm{height} of a \refterm{box} is the distance that the box
extends above its \refterm{baseline}.
^^{boxes//height of}
\endconcept


\conceptindex{horizontal lists}
\concept{horizontal list}

A \defterm{horizontal list} is a list of items 
that \TeX\ has produced while it is
in one of its \refterm{horizontal modes:horizontal mode}, i.e., assembling
either a paragraph or an hbox.  See ``horizontal mode'' below.
\endconcept


\concept {horizontal mode}

^^{hboxes//horizontal mode for}
When \TeX\ is assembling a paragraph or an \refterm{hbox}, it is in one
of two \defterm{horizontal modes}: ^{ordinary horizontal
mode} for assembling paragraphs and ^{restricted horizontal mode} for
assembling hboxes.  Whenever \TeX\ is in a horizontal mode its stomach
\seeconcept{\anatomy} is constructing a \refterm{horizontal
list} of items (boxes, glue, penalties, etc.).
\TeX\ typesets the items in the list
one after another, left to right.

A horizontal list can't contain any
items produced by inherently vertical commands, e.g., |\vskip|.
^^{horizontal lists//can't contain vertical commands}

\ulist
\li If \TeX\ is  assembling a horizontal list in ordinary horizontal mode and
encounters an inherently vertical command, \TeX\ ends the paragraph and
enters \refterm{vertical mode}.

\li If \TeX\ is assembling a horizontal list in restricted horizontal
mode and encounters an inherently vertical command, it complains.
\endulist Two commands that you might at first think are inherently
horizontal are in fact inherently vertical: |\halign| \ctsref{\halign}
and |\hrule| \ctsref{\hrule}.
^^|\hrule//inherently vertical|
^^|\halign//inherently vertical|
See \knuth{page~286} for a list 
of the inherently vertical commands.

{\tighten
You should be aware of a subtle but important property of restricted
horizontal mode: \emph{you can't enter ordinary horizontal mode
when you're in restricted horizontal mode}.  What this means in practice is that
when \TeX\ is assembling an hbox it
won't handle paragraph-like text, i.e., text for which it does
\refterm{line breaking}.  You can get
around this restriction by enclosing the paragraph-like text in a
\refterm{vbox} within the hbox.  The same method works if you want to
put, say, a horizontal \refterm{alignment} inside an~hbox.
}% end scope of tighten

\endconcept


\concept{hyphenation}

\TeX\ automatically hyphenates words as it is processing your document.
\TeX\ is not eager to insert hyphens, preferring instead to find good
line breaks by adjusting the spacing between words and moving words
from one line to another.
\TeX\ is clever enough to understand
hyphens that are already in words.

You can control \TeX's hyphenation in several ways:
\ulist
\li You can tell \TeX\ to
allow a hyphen in a particular place by inserting a
discretionary hyphen
^^{discretionary hyphens}
with the ^|\-| command \ctsref{\@minus}.
\li You can tell \TeX\ how to
hyphenate particular words throughout your document with the ^|\hyphenation|
command \ctsref{\hyphenation}.  
\li You can enclose a word in an \refterm{hbox}, thus preventing \TeX\
from hyphenating it.
\li You can set the value of penalties such as |\hyphenpenalty|
\ctsref\hyphenpenalty.
\endulist
\noindent If a word contains an explicit or discretionary hyphen,
\TeX\ will never break it elsewhere.
\endconcept


\conceptindex{input streams}
\concept {input stream}

See \conceptcit{file}.
\endconcept

\conceptindex{insertions}
\concept insertion

\looseness = -1 
An \defterm{insertion} is a vertical list containing material
to be inserted into
a page when \TeX\ has finished building that page.\footnote
{\tighten 
\TeX\ itself doesn't
insert the material---it just makes the material available to
the output routine, which is then responsible for transferring
it to the composed page.
^^{output routine//insertions, treatment of}
The only immediate effect of the ^|\insert| command
\ctsref{\insert} is to change \TeX's page break calculations so that it
will leave room on the page for the inserted material.  Later, when
\TeX\ actually breaks the page, it divides the inserted material into
two groups: the material that fits on the current page and the material
that doesn't.
^^{page breaks//insertions at}
The material that fits on the page is placed into box registers,
one per insertion,
and the material that doesn't fit is carried over to the next page.
This procedure allows \TeX\ to do such
things as distributing parts of a long footnote over several consecutive
pages.} Examples of such insertions are footnotes and figures.  The
\refterm{\plainTeX} commands for
creating insertions are ^|\footnote|, ^|\topinsert|, |\mid!-insert|,
^^|\midinsert|
and ^|\pageinsert|, as well as the primitive ^|\insert| command
itself (\pp\xrefn\footnote--\xrefn{endofinsert}).
\TeX's mechanism for handling insertions is rather complicated;
see \knuth{pages~122--125} for the details.
\endconcept


\concept {interline glue}

\defterm{Interline glue} is the glue that \TeX\ inserts in front of every
\refterm{box} in a \refterm{vertical list} except for the first one.
The interline glue is ordinarily specified so as to maintain a constant
distance between the baselines of the boxes.  
Its value is jointly determined by the ^|\baselineskip|,
^|\lineskip|, and ^|\lineskiplimit| parameters \ctsref{\baselineskip}.
\endconcept


\conceptindex{items}
\concept item

The term \defterm{item} is often used to refer to a component of
a horizontal, vertical, or math  list, i.e., a list of items that
\TeX\ is building while it is in a horizontal, vertical, or math mode.
\endconcept



\conceptindex{justification}
\concept {justified text} 

\defterm{Justified text} is text that has been typeset so that both
margins are even.  Unjustified text, on the other hand, has been typeset
with ``ragged'' margins on one or both sides.
Documents typed on old-fashioned typewriters almost always have 
ragged right margins.
Although documents produced by \TeX\ are
justified by default, you can if you wish produce documents (or
sequences of lines) that have ^{ragged right}---or ^{ragged left}---margins.
You can also get \TeX\ to center a sequence of lines, thus making both
margins ragged.
^^{centered text}
You can use the 
^|\leftskip|, ^|\rightskip|, and  ^|\raggedright| commands
(\pp \xrefn{\leftskip},~\xrefn{\raggedright}) for these purposes.

When \TeX\ is producing justified text, it usually
needs to stretch or shrink the glue within each line to make the margins
come out even.  When \TeX\ is producing unjustified text, on the other
hand, it usually leaves the glue within each line at its natural width.
Many typographers prefer unjustified text because its interword
spacing is more uniform.
\endconcept


\conceptindex{kerns}
\concept kern

^^{spacing//adjusting with kerns}
A \defterm{kern} indicates a change to the normal spacing between
the items of a vertical or horizontal list.
A kern can be either positive or negative.  By
putting a positive kern between two items, you push them further apart
by the amount of the kern.  By putting a negative kern between two
items, you bring them closer together by the amount of the kern.  For
instance, this text:
\csdisplay
11\quad 1\kern1pt 1\quad 1\kern-.75pt 1
|
produces letter pairs that look like this:
\display{11\quad 1\kern1pt 1\quad 1\kern-.75pt 1}
You can use kerns in vertical mode to adjust the space between 
particular pairs of lines.

A kern of size $d$ is very similar to a \refterm{glue} item that has
size $d$ and no stretch or shrink.  Both the kern and the glue insert or
remove space between neighboring items.  The essential difference is
that \TeX\ considers two boxes with only kerns between them to be tied
together.  That is, \TeX\ won't break a line or a page at a kern unless
the kern is immediately followed by glue.  Bear this difference in mind
when you're deciding whether to use a kern or a glue item for a
particular purpose.

\TeX\ automatically inserts kerns between particular pairs of adjacent
letters, thus adjusting the space between those letters and enhancing
the appearance of your typeset document.  
For instance, the Computer Modern $10$-point roman font contains a kern
for the pair `To' that brings the left edge of the `o' under the
`T'.  Without the kern, you'd get \hbox{``T{o}p''} rather than ``Top''---%
the difference is slight but noticeable.
The metrics file
(^{\tfmfile})
for each \refterm{font} specifies the placement and size of the
kerns that \TeX\ automatically inserts when it is setting text in that~font.
\margin{paragraph deleted to save space; most of the material was
already in this section.}

\endconcept


\concept leaders

You can use \defterm{leaders} to fill a space with copies of
a pattern, e.g.,
to put repeated dots between a title and a page number in a table of contents.
A leader is a single copy of the pattern.
The specification of leaders contains three pieces of information:
\olist\compact
\li what a single leader is
\li how much space needs to be filled
\li how the copies of the pattern should be arranged within the space
\endolist

\bix^^|\leaders|
\bix^^|\cleaders|
\bix^^|\xleaders|
{\tighten
\TeX\ has three commands for specifying leaders:
|\leaders|, \hbox{|\cleaders|}, and |\xleaders| (\xref\leaders).  The 
\refterm{argument} of each command specifies the leader.
The command must be followed by \refterm{glue}; the size of the glue
specifies how much space is to be filled.  The choice of command determines
how the leaders are arranged within the space.}

Here's an example showing how |\leaders| works:
\csdisplay
\def\dotting{\leaders\hbox to 1em{\hfil.\hfil}\hfil}
\line{The Political Process\dotting 18}
\line{Bail Bonds\dotting 26}
|
Here we've put the leaders and their associated glue into a \refterm{macro}
definition so that we can conveniently
use them in two places. This input produces:

\vdisplay{\advance\hsize by -\parindent
\def\dotting{\leaders\hbox to 1em{\hfil{.}\hfil}\hfill}%
\line{The Political Process{\dotting}18}
\line{Bail Bonds{\dotting}26}
}

The \refterm{hbox} following |\leaders| specifies 
the leader, namely, an hbox 1\em\ wide containing a dot
at its center.
The space is filled with copies of this box,
effectively filling it
with dots whose centers are 1\em{} apart.
The following |\hfil| (the one at the
end of the macro definition) is glue that 
specifies the space to be filled.
In this case it's whatever space is needed to fill out the line.
By choosing |\leaders| rather than |\cleaders| or |\xleaders| we've insured
that the dots on different lines line up with each other.

In general, the space to be filled acts as a window
on the repeated copies of the leader.
\TeX\ inserts as many copies as possible, but some space is
usually left over---either because of where the leaders fall
within the window or because
the width of the window isn't an exact multiple of the width of the
leader.
The difference among the three  commands is in how they arrange the leaders
within the window and how they distribute any leftover space:

\ulist
\li For |\leaders|, \TeX\ first produces a row of copies of the leader.
It then aligns the start of this row with the left end of the innermost 
box $B$ that is to contain the result of the |\leaders| command.
In the two-line example above, $B$ is a box produced by |\line|.
Those leaders that fit entirely in the window are placed into $B$,
and the leftover space at the left and right ends is left empty.
The picture is like this:
\vdisplay{%
\def\dotting{\leaders\hbox to 1em{\hfil{.}\hfil}\hfill}%
\def\pp{The Political Process}
\line{\dotting}
\line{\hphantom\pp\hfil$\Downarrow$\hfil\hphantom{18}}
\vskip 4pt
\setbox0 = \hbox{\pp}
\setbox1 = \hbox{18}
\dimen0 = \hsize \advance\dimen0 by -\wd0 \advance \dimen0 by -\wd1
\advance\dimen0 by -0.8pt
\hbadness=10000
\line{\pp
   \vrule\vbox{\hrule width \dimen0\vskip 2pt
   \hbox to \dimen0{\hfil window\strut\hfil}
   \vskip 2pt\hrule width \dimen0}%
   \vrule 18}
\line{\hphantom\pp\hfil$\Downarrow$\hfil\hphantom{18}}
\vskip 2pt
\line{\pp{\dotting}18}
}
\vskip\medskipamount
{\tighten
\noindent
This procedure ensures that in the two-line example on the previous page,
the dots in the two lines
are vertically aligned (since the \refterm{reference points:reference point}
of the hboxes produced by |\line| are vertically aligned).
\par}

\li For |\cleaders|, \TeX\ centers the leaders within the window
by dividing the leftover space between the two ends of the window.
The leftover space is always less than the width of a single leader.

\li For |\xleaders|, \TeX\ distributes the
leftover space evenly within the window.
In other words, if the leftover space is $w$ and the
leader is repeated  $n$ times,
\TeX\ puts space of width $w/(n+1)$ between adjacent leaders and
at the two ends of the leaders.
The effect is usually to spread out the leaders a little bit.
The leftover space for |\xleaders|, like that for |\cleaders|,
is always less than the width of a single leader.
\endulist

So far we've assumed that the leaders consist of hboxes arranged
horizontally.  Two variations are possible:
\olist
\li You can use a
rule instead of an hbox for the leader.
\TeX\ makes the rule as wide as necessary to extend
across the glue (and the three commands are equivalent).
\li You
can produce vertical leaders that run down the page by including them in
a \refterm{vertical list} rather than a \refterm{horizontal list}. In
this case you need vertical glue following the leaders.
\endolist
\noindent
See \knuth{pages~223--225} for the precise rules that \TeX\ uses
in typesetting leaders.
\eix^^|\leaders|
\eix^^|\cleaders|
\eix^^|\xleaders|
\endconcept


\conceptindex{ligatures}
\concept ligature

A \defterm{ligature} is a single character that replaces a
particular sequence of adjacent characters in a typeset document.
For example, the word `|office|' is typeset as \hbox{``office''},
not \hbox{``of{f}ice''}, by high-quality typesetting systems.
Knowledge of ligatures is built into the
\refterm{fonts:font} that you use, so there's nothing explicit you need do
in order to get \TeX\ to produce them.  (You could defeat the ligature
in ``office'', as we did just above, by writing `|of{f}ice|' in your input.)
\TeX\ is also capable of using its ligature mechanism to typeset the
first or last letter of a word differently than the same letter as it would
appear in the middle of a word.
You can defeat this effect (if you ever encounter it) by using the
^|\noboundary| command (\xref\noboundary).

Sometimes you may need a ligature from a European language.
^^{European languages}
\TeX\ won't
produce these automatically unless you're using a font designed for that
language.  A number of these ligatures, e.g., `\AE', are available as
commands (see ``Letters and ligatures for European alphabets'',
\xref{fornlets}).
\endconcept


\conceptindex{line breaks}
\concept{line break}

A \defterm{line break} is a place in your document where \TeX\ ends
a line as it typesets a paragraph.
When \TeX\ processes your document, it collects the contents of each
paragraph in a \refterm{horizontal list}.
When it has collected an entire paragraph,
it analyzes the list to find what it considers to be the best possible
line breaks.  \TeX\ associates ``^{demerits}'' with various symptoms of
unattractive line breaks---lines that have too much or too little
space between words, consecutive lines that end in hyphens, and so forth.  It
then chooses the line breaks so as to minimize the total number of demerits.
See \knuth{pages~96--101} for a full description of \TeX's line-breaking rules.

You can control \TeX's choice of line breaks in several ways:
\ulist

\li You can insert a \refterm{penalty} (\xref{hpenalty}) somewhere in 
the horizontal list that \TeX\ builds as it forms a paragraph.
^^{penalties//in horizontal lists}
A
positive penalty discourages \TeX\ from breaking the line there, while a
negative penalty---a bonus, in other words---encourages \TeX\ to break
the line there.  A penalty of $10000$ or more prevents a line break,
while a penalty of $-10000$ or less forces a line break.  You can get
the same effects with the ^|\break| and
^|\nobreak| commands (\pp\xrefn{hbreak},~\xrefn{hnobreak}).

\li You can tell \TeX\ to allow a hyphen in a particular place by
inserting a discretionary hyphen
^^{discretionary hyphens}
with the |\-| command \ctsref{\@minus}, or
otherwise control how \TeX\ hyphenates your document \seeconcept
{hyphenation}.
^^|\-//in line breaking|

\li You can tell \TeX\ to allow a line break after a ^{solidus} (/) between
two words by inserting ^|\slash| \ctsref{\slash}
between them, e.g., `|fur!-longs\slash fortnight|'.

\li You can tell \TeX\ not to break a line between two particular words by
inserting a ^{tie} (|~|) between those words.
^^|~//in line breaking|

\li You can adjust the penalties associated with line breaking by
assigning different values to \TeX's line-breaking
\refterm{parameters:parameter}.

\li You can enclose a word or sequence of words in an \refterm{hbox}, 
thus preventing \TeX\ from breaking the line anywhere within the hbox.
^^{hboxes//controlling line breaks}
\endulist

It's useful to know the places where \TeX\ can break a line:
\ulist
\li at glue, provided that:
\olist
\li the item preceding the glue is one of the following:
a box, a discretionary item (e.g., a discretionary hyphen),
the end of a math formula,
a whatsit, 
or vertical material produced by |\mark| or |\vadjust|
or |\insert|
\li the glue is not part of a math formula
\endolist
\noindent
When \TeX\ breaks a line at glue, it makes the break at the left edge
of the glue space and forgets about the rest of the glue.
\li at a kern that's immediately followed by glue,
provided that this kern isn't within a math formula
\li at the end of a math formula that's immediately followed by glue
\li at a penalty, even one within a math formula
\li at a discretionary break
\endulist
When \TeX\ breaks a line, it discards any 
sequence of glue, kerns, and penalty items that follows the break point.
If such a sequence is followed by the beginning of a math formula, it
also discards any kern produced by the beginning of the formula.
\endconcept


\conceptindex{lists}
\concept list

A \defterm{list} is a sequence of \refterm{items:item}
(\refterm{boxes:box}, \refterm{glue}, \refterm{kerns:kern}, etc.)
that comprise the contents of an hbox, a vbox,
or a math formula.
See \conceptcit{horizontal list}, \conceptcit{vertical list}.

\endconcept


\concept {log file}

See \conceptcit{file}.
\endconcept


\conceptindex{macros}
\concept macro

{% Use a brace here so that definitions of explanatory macros remain local.
% The closing brace is at the end of the concept.
A \defterm{macro} is a definition that gives a name to a pattern of
\TeX\ input text.\footnote{More precisely, the definition gives a name
to a sequence of tokens.} The name can be either a \refterm{control
sequence} or an \refterm{active character}.  The pattern is called the
``replacement text''.  The primary command for defining macros is the
|\def| control sequence.

\def\arctheta{\cos \theta + i \sin \theta}
As a simple example, suppose that you have a document in which
the sequence `$\cos \theta + i \sin \theta$' occurs many times.
Instead of writing it out each time, you can define a macro for it:
\csdisplay
\def\arctheta{\cos \theta + i \sin \theta}
|
Now whenever you need this sequence, you can just ``call'' the macro
by writing `|\arctheta|'
and you'll get it.  For example, `|$e^{\arctheta}$|' will give you
`$e^{\arctheta}$'.

\bix^^{macros//parameters of}
But the real power of macros lies in the fact that a macro can have
parameters.  When you call a macro that has parameters, you provide 
arguments that are substituted for those parameters.  For example, suppose
you write:
\pix\indexchar #
\def\arc#1{\cos #1 + i \sin #1}
\csdisplay
\def\arc#1{\cos #1 + i \sin #1}
|

The notation |#1| \xrdef{@msharp} indicates the first parameter
of the macro, which in this case has only one parameter.  You now can
produce a similar form, such as `$\arc{2t}$', with the macro call `|\arc
{2t}|'.

More generally, a macro can have up to nine parameters, which you
indicate as `|#1|', `|#2|', etc\null. in the macro definition.  \TeX\
provides two kinds of parameters: delimited parameters and undelimited
parameters.  Briefly, a delimited parameter has an \refterm{argument}
that's delimited, or ended, by a
specified sequence of tokens (the delimiter), while an undelimited
parameter has an argument that doesn't need a delimiter to end it.
First we'll explain how macros work when they have only undelimited
parameters, and then we'll explain how they work when
they have delimited parameters.

^^{parameters//undelimited}
If a macro has only undelimited parameters, those parameters must appear
one after another in the macro definition \emph{with nothing between
them or between the last parameter and the left brace in front of the 
replacement text}.
A call on such a macro consists of the macro name followed by
the arguments of the call, one for each parameter.  Each argument is
either:

\ulist \compact
\li a single \refterm{token} other than a left or right brace, or

\li a sequence of tokens enclosed between a left brace and
a matching right brace.\footnote{The
argument can have nested pairs of braces within it, and each of these
pairs can indicate either a \refterm{group} or a further macro
argument.}
\endulist

When \TeX\ encounters a macro, it expands the macro in its gullet
\seeconcept{\anatomy}
by substituting each argument for the corresponding
parameter in the replacement text.  The resulting text may contain other macro
calls.  When \TeX\ encounters such an embedded macro call, it expands
that call immediately without looking at what follows the
call.\footnote{In computer science terminology, the expansion is ``depth
first'' rather than ``breadth first''.  Note that you can modify the
order of expansion with commands such as |\expandafter|.} When \TeX's
gullet gets to a \refterm{primitive} \refterm{command} that
cannot be further expanded, \TeX\ passes that command to \TeX's stomach.
The order of expansion is sometimes critical, so in order to help
you understand it we'll give you an example of \TeX\ at work.

Suppose you provide \TeX\ with the following input:
\csdisplay
\def\a#1#2{\b#2#1\kern 2pt #1}
\def\b{bb}
\def\c{\char49 cc}
\def\d{dd}
\a\c{e\d} % Call on \a.
|
Then the argument corresponding to |#1| is |\c|,
and the argument corresponding to |#2| is |e\d|.
\TeX\ expands the macro call in the following steps:

{\vskip\abovedisplayskip\obeylines % ugly
|\b e\d\c\kern 2pt \c|
|bbe\d\c\kern 2pt \c|
|\d\c\kern 2pt \c|\quad(`|b|', `|b|', `|e|' sent to stomach)
|dd\c\kern 2pt \c|
|\c\kern 2pt \c|\quad(`|d|', `|d|' sent to stomach)
|\char49 cc\kern 2pt \c|
|\c|\quad(`|\char|', `|4|', `|9|', `|c|', `|c|', %
`|\kern|', `|2|', `|p|', `|t|' sent to stomach)
|\char49 cc|
(`|\char49|', `|c|', `|c|' sent to stomach)
\vskip\belowdisplayskip}

\noindent Note that the letters `|b|', `|c|', `|d|', and `|e|' and the
control sequences `|\kern|' and `|\char|' are all primitive
commands that cannot be expanded further.

\bix^^{parameters//delimited}
A macro can also have ``delimited parameters'', which can be mixed with
the undelimited ones in any combination.  The idea of a delimited
parameter is that \TeX\ finds the corresponding argument by looking for
a certain sequence of tokens that marks the end of the argument---the
delimiter.  That is, when \TeX\ is looking for such an argument, it
takes the argument to be all the tokens from \TeX's current position up
to but not including the delimiter.

You indicate a delimited parameter by writing `|#|$n$' ($n$ 
must be between $0$
and $9$) followed by one or more tokens that act as the delimiter.  The
delimiter extends up to the next `|#|' or `|{|'---which makes sense
since `|#|' starts another parameter and `|{|' starts the replacement text.

The delimiter can't be `|#|' or `|{|', so you can tell a delimited
parameter from an undelimited one by looking at what comes after it. 

If the character after the parameter is `|#|' or `|{|', you've got an
undelimited parameter; otherwise you've got a delimited one.  Note
the difference in arguments for the two kinds of parameters---an
undelimited parameter is matched either by a single token or by
a sequence of tokens enclosed in braces, while a
delimited parameter is matched by any number of tokens, even zero.

An example of a macro that uses two delimited parameters is:
\def\diet#1 #2.{On #1 we eat #2!}
\csdisplay
\def\diet#1 #2.{On #1 we eat #2!!}
|
Here the first parameter is delimited by a single space
and the second parameter is delimited by a period.  If you write:
\csdisplay
\diet Tuesday turnips.
|
you'll get the text ``\diet Tuesday turnips.''.
But if the delimiting tokens are enclosed in a group, \TeX\ doesn't consider
them as delimiting.  So if you write:
\csdisplay
\diet {Sunday mornings} pancakes.
|
you'll get the text `\diet {Sunday mornings} pancakes.'
even though there's a space between `|Sunday|' and `|morning|'.
When you use a space as a delimiter,
an end-of-line character ordinarily also delimits the argument
since \TeX\ converts the end-of-line to a space before the macro
mechanism ever sees it.
\eix^^{parameters//delimited}
\eix^^{macros//parameters of}

Once in a while you might need to define a macro that has `|#|' as a
meaningful character within it.
You're most likely to need to do this when you're defining a macro
that in turn defines a second macro.
What then do you do about
the parameters of the second macro to avoid getting \TeX\ confused?
The answer is that you write
two `|#|'s for every one that you want
when the first macro is expanded.  For example, suppose you 
write the macro definition:
\def\first#1{\def\second##1{#1/##1}}
\csdisplay
\def\first#1{\def\second##1{#1/##1}}
|
Then the call `|\first{One}|' defines `|\second|' as:
\csdisplay
\def\second#1{One/#1}
|
and the subsequent call `|\second{Two}|' produces the text
\def\second#1{One/#1}%
`\second {Two}'.

A number of commands provide additional ways of defining macros
(see pp.~\xrefn{mac1}--\xrefn{mac2}).
For the complete rules pertaining to macros, see \knuth{Chapter~20}.
}% close brace at the start of the `macro' concept.
\endconcept


\concept magnification

When \TeX\ typesets your document, it multiplies all dimensions 
by a 
\refterm{magnification} factor $f/1000$,
where $f$ is the value of the ^|\mag| parameter \ctsref\mag.
Since the default value of |\mag| is $1000$, the normal case is that
your document is typeset just as specified.
Increasing the magnification is often useful when you're typesetting a document
that will later be photoreduced.

You can also apply magnification to a single \refterm{font} so as to get
a smaller or larger version of that font than its ``^{design size}''.  You
need to provide the device driver with a ^{shape file}
\seeconcept{font} for 
each magnification of a font that you're using---%
unless the fonts are built into your printer and your device driver
knows about them.
When you're defining a font with
the |\font| command \ctsref{\font}, you can specify a magnification with
the word `|scaled|'.  For example:

\csdisplay
\font\largerbold = cmbx10 scaled 2000
|
defines `|\largerbold|' as a font that is
twice as big as |cmbx10| (Computer Modern
Bold Extended $10$-point) and has the character shapes
uniformly enlarged by a factor of~$2$.

Many computer centers find it convenient to provide fonts scaled by a ratio
of $1.2$, corresponding to magnification values of $1200$, $1440$, etc.  
\TeX\ has special names for these values:
^^|\magstep|
`|\magstep1|' for $1200$,
`|\magstep2|' for $1440$, and so forth up to `|\magstep5|'.  The special
value `^|\magstephalf|' corresponds to magnification by $\sqrt{1.2}$, which
is visually halfway between `|\magstep0|' (no magnification) and
`|\magstep1|'.  For example:

\csdisplay
\font\bigbold = cmbx10 scaled \magstephalf
|

You can specify a \refterm{dimension} as it will be
measured in the final document independent of magnification by putting
`^|true|' in front of the unit.  For instance, `|\kern 8 true pt|' 
produces a kern of $8$ points whatever the magnification. 

\endconcept

\concept margins

The \refterm{margins}
of a page define a rectangle that normally
contains the printed matter on the page.
You can get \TeX\ to print material outside of this rectangle,
but only by taking some explicit action that moves the material there.
\TeX\ considers headers and footers to lie outside the margins.

The rectangle is defined in terms of its upper-left corner, its width, and
its depth.  The location of the upper-left corner is defined by
the ^|\hoffset|
and ^|\voffset| parameters
\ctsref\voffset.  The default is to place that corner one inch from the top
and one inch from the left side of the page, corresponding to a value of
zero for both |\hoffset| and |\voffset|.%
\footnote{This seems to us to be an odd convention.
It would have been more natural to have the $(0,0)$
point for |\hoffset| and |\voffset| be at the upper-left corner of the
paper and to have set their default values to one inch.}
The width of the rectangle is given by ^|\hsize| and the depth by ^|\vsize|.

The implications of these conventions are:
\ulist\compact
\li The left margin is given by |\hoffset|\tplus|1in|.
\li The right margin is given by the width of the paper minus 
    |\hoffset|\tplus|1in|\tplus|\hsize|.
\li The top margin is given by |\voffset|\tplus|1in|.
\li The bottom margin is given by the length of the paper minus
    |\voff!-set|\tplus|1in|\tplus|\vsize|.
\endulist
From this information you can see what parameters you need to
change in order to change the margins.

Any changes that you make to |\hoffset|, |\voffset|, or |\vsize| become
effective the next time \TeX\ starts a page.  In other words, if you change
them within a page, the change will affect only the \emph{following} pages.
If you change |\hsize|, the change will become effective immediately.
\endconcept


\conceptindex{marks}
\concept mark

A \defterm{mark} is an item that you can insert into a
horizontal, vertical, or math list and later recover from within your
output routine.  Marks are useful for purposes such as
keeping track of topics to appear in page headers.
Each mark has a list of tokens---the ``^{mark text}''---associated with it.
The ^|\mark| command \ctsref{\mark} expects such a token list as its argument,
and appends an item containing that token list (after
expansion) to whatever list \TeX\ is
currently building.  The ^|\topmark|, ^|\firstmark|, and ^|\botmark| commands
\ctsref{\topmark} can be used to retrieve various marks on a page.
These commands are most often used in page headers and footers.
^^{footers//marks used in}
^^{headers//marks used in}

\margin{This example of {\tt\\mark} replaces the previous explanatory
paragraph.}
Here is a simplified example.
Suppose you define a section heading macro as follows:
\csdisplay
\def\section#1{\medskip{\bf#1}\smallskip\mark{#1}}
% #1 is the name of the section
|
^^|\mark|
This macro, when called, will produce a section heading in boldface and
will also record the name of the section as a mark.
You can now define the header for each printed page
as follows:
\csdisplay
\headline = {\ifodd\pageno \hfil\botmark\quad\folio
   \else \folio\quad\firstmark\hfil \fi}
|
Each even (left-hand) page will now have the page number followed by the
name of the first section on that page, while each odd (right-hand) page
will have the page number followed by the name of the last section on
that page.  Special cases, e.g., no sections starting on a page, will
generally come out correctly because of how ^|\firstmark|
and ^|\botmark| work.

When you split a page using the |\vsplit| command \ctsref{\vsplit} you can
retrieve the mark texts of the first and last marks of the split-off
portion with the ^|\splitfirstmark| and ^|\splitbotmark| commands
\ctsref{\splitfirstmark}.

See \knuth{pages~258--260} for a more precise explanation of how
to create and retrieve marks.
\endconcept


\concept math mode

{\tighten
A \defterm{math mode} is a \refterm{mode} that \TeX\ is in when it is
building a math formula.  \TeX\ has two different math modes: ^{text
math mode} for building a formula to be embedded within a line of text,
and ^{display math mode} for building a formula to appear on a line by
itself.  You indicate text math mode by enclosing the formula in
|$|'s, and display math mode by enclosing the formula in
|$$|'s.
%\TeX\ will accept most \refterm{commands:command} in
%math mode. If it encounters a command in math mode that doesn't make
%sense in a formula, it will complain.
An important property of both
math modes is that \emph{input spaces don't count}.  See
\knuth{pages~290--293} for details on how \TeX\ responds to different
commands in math mode.
\par}

\endconcept


\conceptindex{mathcodes}
\concept mathcode

A \defterm{mathcode} is a number that \TeX\ uses to identify and
describe a math character,
^^{math characters//described by mathcodes}
i.e., a character that has a
particular role in a math formula.  A mathcode conveys three pieces of
information about a character: its \refterm{font} position, its
\refterm{family}, and its \refterm{class}.
Each of the $256$ possible
input characters has a mathcode, which is defined by the \TeX\ program
but can be changed.

^^{family//as part of mathcode}
\TeX\ has sixteen families of fonts, numbered $0$--$15$.  Each
family contains three fonts: one for \refterm{text size}, one for
\refterm{script size}, and one for \refterm{scriptscript size}.  \TeX\
chooses the size of a particular character, and therefore its font,
according to the context.  The class of a character specifies its role
in a formula (see \knuth{page~154}).  For example, the equals sign `|=|'
is in class $3$ (Relation).  \TeX\ uses its knowledge of character
classes when it is deciding how much space to put between different
components of a math formula.

The best way to understand what mathcodes are all about is to see how
\TeX\ uses them. So we'll show you what \TeX\ does with a
character token $t$ of \refterm{category code}~11 or~12 in a math
formula:

\olist\compact
\li It looks up the character's mathcode.
\li It determines a family $f$ from the mathcode.
\li It determines the size $s$ from the context.
\li It selects a font $F$ by picking the font for size $s$ in family $f$.
\li It determines a character number $n$ from the mathcode.
\li It selects as the character $c$ to be typeset the character
at position $n$ of font $F$.
\li It adjusts the spacing around $c$ according to the class of $t$ and
the surrounding context.
\li It typesets the character $c$.
\endolist

The context dependence in
items (3) and (7) implies that \TeX\ cannot typeset a math character
until it has seen the entire formula containing the
math character.  For example, in the formula
`|$a\over b$|', \TeX\ doesn't know what size the `|a|' should be until it
has seen the |\over|.

{\tighten
The mathcode of a character is encoded according to the formula $4096c
+ 256f + n$, where $c$ is the class of the character, $f$ is its
\refterm{family}, and $n$ is its \refterm{\ascii\ character} code within
the family.  You can change \TeX's interpretation of an input character
in math mode by assigning a value to the ^|\mathcode|
table entry \ctsref{\mathcode}
for that character.  The character must have a
\refterm{category code} of $11$ (letter) or $12$ (other) for \TeX\ to
look at its |\mathcode|.
}\par

^^{family//variable}
You can define a mathematical character to have a ``variable'' family by
giving it a class of $7$.  Whenever \TeX\ encounters that character in a
math formula, it takes the family of the character to be the current
value of the |\fam| parameter \ctsref{\fam}.  A variable family enables
you to specify the font of ordinary text in a math formula.  For
instance, if the roman characters are in family $0$, the assignment
|\fam = 0|
will cause ordinary text in a math formula to be set in roman type
rather than in something else like math italic type. If the value of
|\fam| is not in the range from $0$ to $15$, \TeX\ takes the value to be
$0$, thus making classes $0$ and $7$ equivalent.
\TeX\ sets |\fam| to $-1$ whenever it enters math mode.
\endconcept


\conceptindex{mathematical units}
\concept{mathematical unit}

A \defterm{mathematical unit}, denoted by `|mu|', is a unit of distance
that is used to specify \refterm{glue} in math formulas.  See
\conceptcit{muglue}.
\endconcept


\conceptindex{modes}
\concept mode

When \TeX\ is processing your input in its stomach \seeconcept{\anatomy},
it is in one of six \defterm{modes}:
\ulist\compact
\li ^{ordinary horizontal mode} (assembling a paragraph)
\li ^{restricted horizontal mode} (assembling an \refterm{hbox})
\li ^{ordinary vertical mode} (assembling a page)
\li ^{internal vertical mode} (assembling a \refterm{vbox})
\li ^{text math mode} (assembling a formula that appears in text)
\li ^{display math mode}
(assembling a formula that appears on a line by~itself)
^^{horizontal mode}^^{vertical mode}^^{math mode}
\endulist
The mode describes the kind of entity that \TeX\ is putting together.

Because you can embed one kind of entity within another, e.g., a vbox
within a math formula, \TeX\ keeps track not just of one mode but of a
whole list of modes (what computer scientists call a ``stack'').
Suppose that \TeX\ is in mode $M$ and encounters something that
puts it into a new mode \Mprimeperiod.  When it finishes its work in
mode \Mprimecomma, it resumes what it was doing in mode \Mperiod.

\endconcept


\concept muglue

\defterm{Muglue} is a kind of \refterm{glue} that you can use only in math
formulas.  It is measured in ^|mu| (\refterm{mathematical
units:mathematical unit}).
^^{mathematical units}^^{glue//mathematical}
One |mu| is equal to \frac1/{18} em, where
the size of an em is taken from \refterm{family} 2 of the math fonts.
\TeX\ automatically adjusts the size of muglue according to the context.
For instance, a glue size of |2mu| is normally smaller within a
subscript than it is within ordinary text.  
You must use the ^|\mskip| command to produce muglue.
For example, `|\mskip 4mu plus 5mu|' produces mathematical glue with
natural space of four |mu| and \refterm{stretch} of five |mu|.

\endconcept


\conceptindex{numbers}
\concept number

In \TeX, a \defterm{number} is a positive or negative integer.
You can write a number in \TeX\ in four different ways:
\olist\compact
\li as an ordinary decimal integer, e.g., |52|
\li as an octal number, e.g., |'14| ^^{octal numbers}
\li as a hexadecimal number, e.g., |"FF0| ^^{hexadecimal numbers}
\li as the code for an \refterm{\ascii\ character}, e.g., |`)|
or |`\)|
\endolist
\noindent 
Any of these forms can be preceded by `|+|' or `|-|'.

An octal number can have only the digits |0|--|7|.
^^{octal numbers}
A hexadecimal number can have digits |0|--|9| and
|A|--|F|, representing
values from $0$ to $15$.
^^{hexadecimal numbers}
You can't, alas, use lowercase letters when you write a hexadecimal number.
If you need an explanation of octal and hexadecimal numbers,
you'll find one on \knuth{pages~43--44}.

A decimal, octal, or hexadecimal number 
ends at the first character that can't be part of the number.
Thus a decimal number ends when \TeX\ sees, say, a letter, even though a
letter between `|A|' and `|F|' would not end a hexadecimal number.
You can end a number with one or more spaces and
\TeX\ will ordinarily ignore them.\footnote{
When you're defining a macro that ends in a number, you should always
put a space after that number; otherwise \TeX\ may later combine that
number with something else.}

The fourth form above specifies a number as the 
\minref{\ascii} code for a character.
^^{characters//\ascii\ codes for}
\TeX\ ignores spaces after this form of number also.
You can write a number in this form either as |`|$c$ or as |`\|$c$.
The second form, though longer, has the advantage that you can use it
with \emph{any} character, even `|\|', `|%|', or `|^^M|'.
It does have one rather technical disadvantage: when \TeX\ is expanding
a token sequence for a command such as |\edef| or |\write|,
^^|\edef//expansion of {\tt\\'\it c} in|
^^|\write//expansion of {\tt\\'\it c} in|
occurrences of `|\|$c$' within numbers will also be expanded if they can be.
That's rarely the effect you want.

The following are all valid representations of the decimal number
$78$:
\csdisplay
78   +078   "4E   '116   `N   `\N
|


You can't use a number in text by itself since a number isn't
a command.
However, you can insert the decimal form of a number in text
by putting a ^|\number| command (\xref\number) in front of it
or the roman numeral form by putting a ^|\romannumeral| command
in front of it.

You can also use ^{decimal constant}s, i.e., numbers with a fractional part,
for specifying dimensions \seeconcept{dimension}.
A decimal constant has a ^{decimal point}, which
can be the first character of the constant.  
You can use a comma instead of a period to represent the decimal point.
A decimal constant can be preceded by a plus or minus sign.
Thus `|.5in|', 
`|-3.22pt|', and `|+1,5\baselineskip|' are valid dimensions.
You can't, however, use decimal constants
in any context \emph{other} than as the ``factor'' part of a dimension,
i.e., its multiplier.


\endconcept


\concept{ordinary mode}

An \defterm{ordinary mode} is a \refterm{mode} that \TeX\ is in when it is
assembling a paragraph into lines or assembling lines
into a page.  See \conceptcit{horizontal mode}, \conceptcit{vertical mode}.
\endconcept


\concept outer

\bix^^{macros//outer}
An \defterm{outer} macro is one that you can't use in certain contexts
where \TeX\ is processing tokens at high speed.
The purpose of making a command outer is to enable \TeX\ to catch
errors before it's gone too far.
When you define a macro, you can make it outer with the 
^|\outer| command \ctsref\outer.

You cannot use an outer macro in any of the following contexts:
\ulist\compact
\li within an argument to a macro
\li in the parameter text or replacement text of a definition
\li in the preamble to an alignment
\li in the unexecuted part of a conditional test
\endulist
\noindent
An outer context is a context in which you can use an outer macro,
i.e., it's any context other than the ones just listed.

For example, the following input would be a forbidden use of an
outer macro:
\csdisplay
\leftline{\proclaim Assertion 2. That which is not inner
   is outer.}
|
The |\proclaim| macro (\xref{\@proclaim}) is defined in \plainTeX\
to be outer, but it's being used here in a macro argument to |\leftline|.
\eix^^{macros//outer}

\endconcept


\concept {output routine}

When \TeX\ has accumulated
at least enough material to fill up a page, it chooses a breakpoint
and places the material before the breakpoint in |\box255|. It then
calls the
current \defterm{output routine}, which processes the material and eventually
sends it to the \dvifile.
^^{\dvifile//material from output routine}
The output routine can perform further
processing, such as inserting headers, footers, and footnotes.  
\refterm{\PlainTeX:\plainTeX} provides
a default output routine that inserts a centered page number
at the bottom of each page.  
By providing a different output routine you can achieve such
effects as double-column output.
You can think of the output routine as having a single responsibility:
disposing of the material in |\box255| one way or another.

The current output routine is defined by the value of ^|\output|
\ctsref{\output}, which is a list of \refterm{tokens:token}.  When \TeX\
is ready to produce a page, it just expands the token list.

You can make some simple changes to the actions of the \plainTeX\
output routine without actually modifying it.  For example, by assigning
a list of \refterm{tokens:token} to |\headline| or
|\footline| \ctsref{\footline} you can have \TeX\ produce a different
header or footer than it ordinarily would.

The output routine is also
responsible for collecting any \refterm{insertions:insertion};
combining those insertions and any
``decorations'' such as headers and
footers with the main contents of the page and packaging all
of this material in a box; and
eventually sending that box to the \dvifile\ 
^^{\dvifile//material from output routine}
with the ^|\shipout|
command \ctsref{\shipout}.
Although this is what an output routine most often does,
a special-purpose output routine might behave differently.
\endconcept


\conceptindex{output streams}
\concept {output stream}

\margin{This concept was out of order.}
See \conceptcit{file}.
\endconcept


\conceptindex{pages}
\concept page

\TeX\ processes a document by assembling \defterm{pages} one at a time
and passing them to the output routine.
As it proceeds through your document, \TeX\ maintains a list of lines
and other 
items to be placed on the page.  (The lines are actually hboxes.)
This list is called the ``^{main vertical list}''. 
Periodically \TeX\ goes through a process called ``exercising the
^{page builder}''.
The items added to the main vertical list between exercises of the
page builder are called ``^{recent contributions}''.

The page builder first examines the main vertical list to see if it's
necessary to ship out a page yet, either because the items on the main
vertical list won't all fit on the page or because of an explicit item,
such as |\eject| \ctsref\eject, that tells \TeX\ to end the page.
If it's not necessary to ship out a page, then the page builder is done
for the time being.

Otherwise the page builder analyzes the main vertical
list to find what it considers to be the best possible page break.
It  associates penalties with various kinds of unattractive page
breaks---a break that would leave an
isolated line at the top or bottom of a page, a break just before a
math display, and so forth.  It then
chooses the least costly page break,
where the cost of a break is increased by any penalty associated with that
break and by the badness of the page that would result
(see \knuth{page~111} for the cost formula).  If it finds several
equally costly page breaks, it chooses the last one.

{\tighten
Once the page builder has chosen a page break,
it places the items on the list that are before that break
into ^|\box255| and leaves the remaining ones for the next page.
It then calls the output routine. |\box255| acts as a mailbox, with the
page builder as the sender and the output routine as the receiver.
Ordinarily the output routine processes |\box255|, adds
other items, such as insertions, headers, and footers, to the page, and
ships out the page to the \dvifile\
^^{\dvifile//material from output routine}
with a |\shipout| command.
(Specialized output routines may behave differently.)
From \TeX's standpoint, it doesn't matter whether or not the output
routine ships out a page;
the only
responsibility of the output routine is to process |\box255| one way or
another.
\par}

{\tighten
It's important to realize that the best place to break a page isn't
necessarily the last possible place to break the page.
Penalties and other considerations may cause the page break
to come earlier.
Furthermore, \TeX\ appends items to the main vertical list in batches,
not just singly.
The lines of a paragraph are an example of such a batch.
For these reasons the page builder usually has items left over when it
breaks a page.
These leftover items then form the beginning of the main vertical list
for the next page (possibly in the middle of a batch).
Because items are carried over from one page to another,
you can't assume that as \TeX\ is processing
input, the current page number accurately reflects the page on which the
corresponding output will appear.  See \knuth{pages~110--114} for a full
description of \TeX's page-breaking rules.
\par}

\endconcept


\conceptindex{page breaks}
\concept{page break}

A \defterm{page break} is a place in your document where \TeX\ ends a
page and (except at the end of the document) starts a new one.  
See \conceptcit{page} for the process that \TeX\ goes through in choosing
a page break.

You can control \TeX's choice of page breaks in several ways:
\ulist
\li You can insert a penalty (\xref{vpenalty}) 
^^{penalties//in vertical lists}
between two items in the main vertical list.  A positive
penalty discourages \TeX\ from breaking the page 
there, while a negative penalty---a bonus, in other words---%
encourages \TeX\ to break the page there.  A penalty of $10000$
or more prevents a
page break, while a penalty of $-10000$ or less forces a page break.
You can get the same effects with the |\break| and
|\nobreak| commands \ctsref{vbreak}.

\li You can adjust the penalties associated with page breaking
by assigning different values to \TeX's page-breaking
\refterm{parameters:parameter}.

\li You can enclose a sequence of paragraphs 
or other items in the main vertical list within a \refterm{vbox}, 
thus preventing \TeX\ from breaking the page anywhere within the sequence.
\endulist

Once \TeX\ has chosen a page break, it places the portion of the main vertical
list that precedes the break into |\box255|.
It then calls the current \refterm{output routine}
to process |\box255| and eventually ships its contents to the \dvifile.
^^{\dvifile//material from output routine}
The output routine must
also handle \refterm{insertions}, such as footnotes, that \TeX\ has accumulated
while processing the page.

It's useful to know the places where \TeX\ can break a page:
\ulist
\li At glue, provided that the item preceding the glue is
a box, a whatsit, a mark, or an insertion.
When \TeX\ breaks a page at glue, it makes the break at the top
of the glue space and forgets about the rest of the glue.
\li At a kern that's immediately followed by glue.
\li At a penalty, possibly between the lines of a paragraph.
\endulist
When \TeX\ breaks a page, it discards any 
sequence of glue, kerns, and penalty items that follows the break point.


\endconcept


\concept page builder

See \conceptcit{page}.
\endconcept


\concept {page layout}

\bix^^{margins}
\bix^^{headers}
\bix^^{footers}
When you're designing a document, you need to decide on its
\defterm{page layout}: the page size,
the margins on all four sides, the headers and footers, if any,
that appear at the top and bottom of the page,
and the amount of space between the body of the text and the headers or
footers.  \TeX\ has defaults for all of these.  It assumes an $8 \frac1/2$-%
by-$11$-inch page with margins of approximately one inch
on all four sides, no header,
and a footer consisting of a centered page number.

The margins are determined jointly by the four parameters
^|\hoffset|, ^|\voffset|, ^|\hsize|, and ^|\vsize| (see
``margins'', \xrefpg{margins},
for advice on how to adjust them).
\eix^^{margins}
The header normally consists of a single line that appears at the top of each
page, within the top margin area.  You can set it by assigning
a \refterm{token} list to the ^|\headline| parameter (\xref{\headline}).
Similarly,
the footer normally consists of a single line that appears at the bottom
of each
page, within the bottom margin area.  You can set it by assigning
a \refterm{token} list to the ^|\footline| parameter (\xref{\footline}).
For example, the input:
\csdisplay
\headline = {Baby's First Document\dotfill Page\folio}
\footline = {\hfil}
|
produces a header line like this on each page:
\vdisplay{
\dimen0 = \hsize
\advance \dimen0 by -\parindent
\hbox to \dimen0{Baby's First Document\dotfill Page 19}}
\noindent
and no footer line.

You can use marks to place the current topic of a section
of text into the header or footer.
^^{marks//with headers or footers}
See \conceptcit{mark} for an explanation of how to do this.
\eix^^{headers}
\eix^^{footers}
\endconcept

\conceptindex{paragraphs}
\concept paragraph

Intuitively, a \defterm{paragraph} is a sequence of input lines that's
ended by a blank line, by a ^|\par| command \ctsref{\@par},
^^|\par//ending a paragraph with|
or by an intrinsically vertical command, such as |\vskip|.
More precisely, a paragraph is a sequence of commands that \TeX\ processes
in ordinary horizontal mode.
When \TeX\ has collected an entire paragraph, it forms it into a sequence of
lines by choosing line breaks \seeconcept{line break}.
The result is a list of hboxes with glue, interline penalties,
and interspersed vertical material between them.
Each hbox is a single line, and the glue is the interline glue.

\eject
\TeX\ starts a paragraph when it's in a vertical mode
and encounters an inherently horizontal command.
In particular, it's in a vertical mode when it's just finished a paragraph,
so the horizontal material on the line after a blank input line starts the
next paragraph in a natural way.
There are many kinds of inherently horizontal commands, but the most common
kind is an ordinary character, e.g., a letter.

\looseness = -1
The ^|\indent| and ^|\noindent| commands
(\pp\xrefn{\indent},~\xrefn{\noindent})
are also inherently horizontal commands that tell
\TeX\ either to indent or not to indent the beginning of a paragraph.
Any other horizontal command in vertical
mode causes \TeX\ to do an implicit |\indent|.
Once \TeX\ has started a paragraph, it's in ordinary horizontal mode.
It first obeys any commands that are in ^|\everypar|.
It then proceeds to collect items for the paragraph until it gets a signal
that the paragraph is ended.
At the end of the paragraph it
resets the paragraph shape parameters ^|\parshape|, |\hang!-indent|,
^^|\hangindent| 
and ^|\looseness|.

\TeX\ ordinarily translates a blank line into |\par|.  
It also
inserts a |\par| into the input whenever it's in horizontal mode and
sees an intrinsically vertical command.
So ultimately the thing that ends a paragraph is always a |\par| command.

When \TeX\ receives a |\par| command, it first
fills out\footnote{%
More precisely, it executes the commands:
\csdisplay
\unskip \penalty10000 \hskip\parfillskip
|
thus appending items for these commands
to the end of the current horizontal list.}
the paragraph it's working on.
It then breaks the paragraph into lines,
adds the resulting list of items to the enclosing vertical list,
and exercises the page builder 
(in the case where the enclosing vertical list is the main vertical list).
If the paragraph was ended by an intrinsically vertical command,
\TeX\ then executes that command.

\endconcept

\conceptindex{parameters}
\concept parameter

The term \defterm{parameter} has two different meanings---it can refer
either to a \TeX\ parameter or to a macro parameter.

A \TeX\ parameter is a \refterm{control sequence} that names
a value.
The value of a parameter can be a \refterm{number}, a \refterm{dimension},
an amount of \refterm{glue} or muglue, or a \refterm{token list}.
For example, the ^|\parindent| parameter
specifies the distance that \TeX\ skips at the start of an
indented  paragraph.

You can use the control sequence for a parameter either to retrieve the value
of the parameter or to set that value.  \TeX\ interprets the control sequence
as a request for a value if it appears in a context where a value is expected,
and as an \refterm{assignment} otherwise.
^^{assignments}
For example:
\csdisplay
\hskip\parindent
|
produces horizontal \refterm{glue} whose natural size is given by |\parindent|,
while:
\csdisplay
\parindent = 2pc  % (or \parindent 2pc)
|
sets |\parindent| to a length of two picas.  The assignment:
\csdisplay
\parindent = 1.5\parindent
|
uses |\parindent| in both ways.  Its effect is to multiply the value of
|\parindent| by $1.5$.

You can think of a parameter as a built-in \refterm{register}.
^^{registers//parameters as}
You'll find a complete list of the \TeX\ parameters on \knuth{pages~272--275}.

A \refterm{macro} parameter is a placeholder for text that is to be
plugged into the definition of a macro.  See \conceptcit{macro}
for more information about this kind of parameter.

\endconcept


\conceptindex{penalties}
\concept penalty

A \defterm{penalty} is an item that you can include in a 
horizontal, vertical, or math list
in order to discourage \TeX\ from breaking the list
at that point or encourage \TeX\ to break the list there.  
^^{horizontal lists//penalties in}
^^{vertical lists//penalties in}
A positive penalty indicates a bad break point, while
a negative penalty indicates a good break point.
Breaking an
ordinary horizontal
list produces a \refterm{line break}, while breaking an
ordinary vertical list produces
a \refterm{page break}.  
(A penalty has no effect in restricted horizontal or 
internal vertical \refterm{mode}.)

You can use the
|\penalty| command (\pp\xrefn{hpenalty},~\xrefn{vpenalty})
to insert a penalty explicitly.
A penalty of $10000$ or more prevents a break, while a penalty of
$-10000$  or less forces a break.
\endconcept


\concept{\plainTeX}

\defterm{\PlainTeX} is the form of \TeX\ described in this
book and in \texbook.  \PlainTeX\ is part of the standard \TeX\
system, so documents that use only the facilities of \plainTeX\ can
usually be transferred from one installation to another without
difficulty.

\PlainTeX\ consists of the \refterm{primitive} commands together with a
large collection of macros and
other definitions.  These additional definitions are given in
\knuth{Appendix~B}.  They should also be in the file |plain.tex|
somewhere in your computer system.
\endconcept


\concept{primitive}

A \defterm{primitive} \refterm{command} is one whose definition is built
into the \TeX\ computer program.  In contrast, a command that is not
primitive is defined by a \refterm{macro} or some other form of
definition written in \TeX\ itself.  The commands in \refterm{\plainTeX}
consist of the primitive commands together with
other commands defined in terms of the
primitive ones.
\endconcept


\concept {reference point}

^^{baselines}
^^{boxes//reference point of}
The \defterm{reference point} of a \refterm{box} is the point where the
left edge of the box intersects its \refterm{baseline}.  When \TeX\ is
processing a \refterm{horizontal:horizontal list} or \refterm{vertical
list}, it uses the reference points of the boxes in the list to line up
those boxes horizontally or vertically \seeconcept{box}.
\endconcept

\conceptindex{registers}
\concept register

A \defterm{register} is a named location for storing a value.
It is much like a variable in a programming language.
\TeX\ has five kinds of registers, as shown in the following table:

\vdisplay{\tabskip 10pt\halign{\tt #\hfil &#\hfil\cr
{\it Register type}&{\it Contents}\cr
box&a \refterm{box} \idxref{box registers}\cr
count&a \refterm{number} \idxref{count registers}\cr
dimen&a \refterm{dimension} \idxref{dimension registers}\cr
muskip&\refterm{muglue} \idxref{muglue registers}\cr
skip&\refterm{glue} \idxref{glue registers}\cr
toks&a \refterm{token} list\idxref{token registers}\cr}}

The registers of each type are numbered from $0$ to $255$.
You can access register $n$ of category $c$ by using the form `|\|$cn$',
e.g., |\muskip192|.
You can use a register
anywhere that information of the appropriate type is called for.  For
instance, you can use |\count12|
in any context calling for a number or |\skip0|
in any context calling for glue.

You put information into a register by \refterm{assigning:assignment}
something to it:

\csdisplay
\setbox3 = \hbox{lagomorphs are not mesomorphs}
\count255 = -1
|
The first assignment constructs an hbox and assigns it to
box register~$3$.
You can
subsequently use `|\box3|' wherever a box is called for, and you will
get just that hbox.\footnote{But note carefully: using a box register
also empties it so that its contents become void.  The other kinds of
registers don't behave that way. You can use the |\copy| command
\ctsref{\copy} to retrieve the contents of a box register without
emptying it.}
The second assignment assigns $-1$ to count register~$255$.

A register of a given type, e.g., a glue register, behaves just like
a parameter of that type.
^^{parameters//like registers}
You retrieve its value or assign to it
just as you would with a \refterm{parameter}.
Some \TeX\ parameters, e.g., |\pageno|,
are implemented as registers, in fact.

\PlainTeX\
uses many registers for its own purposes, so you should not just
pick an arbitrary
register number when you need a register.  Instead you should ask
\TeX\ to reserve a register by using one of the commands
^|\newbox|, ^|\newcount|, ^|\newdimen|, ^|\newmuskip|, ^|\newskip|,
or ^|\newtoks|
\ctsref{\@newbox}.  These commands are outer, so you can't
use them in a macro definition.
If you could,
you'd use up a register every time the macro was called and probably run out
of registers before long.

Nonetheless you can with some caution use any register temporarily
within a \refterm{group}, even one that \TeX\ is using for something
else.
After \TeX\ finishes executing the commands in a group,
it restores the contents of every register
to what they were before it started executing the group.
When you use an explicitly numbered register inside a group,
you must be sure that the register isn't modified by any
\refterm{macro}
that you might call within the group.
Be especially careful
about using arbitrary registers in a group that calls macros 
that you didn't write yourself.

{\tighten
\TeX\ reserves certain registers for special purposes: |\count0| through
|\count9| for page numbering information and
^^{page numbering}
^|\box255| for the contents
of a page just before it is offered to the \refterm{output routine}.
Registers |\dimen0|--|\dimen9|, |\skip0|--|\skip9|,
|\muskip0|--|\mu!-skip9|, |\box0|--|\box9|,
and the |255| registers other than |\box255|
are generally available as ``scratch'' registers.
Thus \plainTeX\ provides only one scratch register, |\count255|, for
counts.
See \knuth{pages~122 and 346} for conventions to follow
in choosing register numbers.
\par}

You can examine the contents of registers during a \TeX\ run with the
^|\showthe| command \ctsref\showthe, e.g., with `|\showthe\dimen0|'.
\endconcept


\concept{restricted mode}

A \defterm{restricted mode} is a \refterm{mode} that \TeX\ is in when it is
assembling an \refterm{hbox} or a \refterm{vbox}.
We follow \texbook\ in using the term ``internal vertical mode''
for what you might expect to be ``restricted vertical mode''.
See \conceptcit{horizontal
mode} and \conceptcit{vertical mode}.\endconcept


\conceptindex{rules}
\concept rule

A \defterm{rule} is a solid black rectangle.
A rule, like a \refterm{box},
has \refterm{width}, \refterm{height}, and \refterm{depth}.
The vertical dimension of the rectangle
is the sum of its height and its depth.
An ordinary horizontal or vertical straight line is a special case of a rule.
 
\bix^^{horizontal rules}
\bix^^{vertical rules}
\bix^^|\hrule|
\bix^^|\vrule|
A rule can be either horizontal or vertical.  The distinction between a
horizontal rule and a vertical one has to do with how you produce the
rule, since a vertical rule can be short and fat (and therefore look
like a horizontal line), while a horizontal rule can be tall and skinny
(and therefore look like a vertical line).  \TeX's notion of a rule is
more general than that of typographers, who think of a rule as a line
and would not usually call a square black box a rule.
 
You can produce a horizontal rule using the
|\hrule| command and a vertical rule using
the |\vrule| command \ctsref{\vrule}.
For example, the control sequence |\hrule| by itself
produces a thin rule that runs across the page, like this:

{\offinterlineskip
\nobreak\medskip
\hrule
\medskip}

The command `|\vrule height .25in|' produces a vertical rule
that runs $.25$~inches down the page like this:
\nobreak\vskip \abovedisplayskip
\leftline{\vrule height .25in}
\vskip \belowdisplayskip

There are two differences between horizontal rules and vertical rules:
\olist
\li For a horizontal rule, \TeX\ defaults the width to the width of the
smallest \refterm{box} or \refterm{alignment} that encloses it.  For a
vertical rule, \TeX\ defaults the height and depth in the same way.  (The
default is the size that you get if you don't give a size explicitly for that
dimension.)

^^{horizontal lists//rule in}
^^{vertical lists//rule in}
\li 
{\tighten
A horizontal rule is an inherently vertical item that cannot participate in
a \refterm{horizontal list},
while a vertical 
rule is an inherently horizontal item
that cannot participate in a \refterm{vertical list}.  This behavior
may seem strange at first but there is good reason for it:
a horizontal rule ordinarily runs visually from left 
to right and thus separates items in a vertical list,
while a vertical rule ordinarily runs visually from top to bottom
and thus separates items in a horizontal list.
%(Look at the rules that are shown above.)
\par}
\endolist

{\tighten
If you construct a rule with three explicit dimensions, it will look the
same whether you make it a horizontal rule or a vertical rule.
For example, the command `|\vrule height1pt depth2pt width3in|' produces this
horizontal-looking rule:
\par}

{\offinterlineskip
\nobreak\medskip\nobreak\vskip3pt
\leftline{\vrule height1pt depth2pt width3in}
\medskip}

You'll find a precise statement of \TeX's treatment of rules on
\knuth{pages~221--222}.
\eix^^{horizontal rules}
\eix^^{vertical rules}
\eix^^|\hrule|
\eix^^|\vrule|
\endconcept


\concept {script size} 

\defterm{Script size} describes one of the three related
\refterm{fonts:font} in a family.
^^{family//script size in}
Script size is smaller than \refterm{text size} but larger than
\refterm{scriptscript size}.  \TeX\ uses script size for subscripts and
superscripts, as well as for the numerators and denominators of
fractions in text.
\endconcept


\concept {scriptscript size}

\defterm{Scriptscript size} describes the smallest of the three related
\refterm{fonts:font} in a family.
^^{family//scriptscript size in}
\TeX\ uses \refterm{scriptscript size} for second-order subscripts,
superscripts, numerators, and denominators.  For example, \TeX\ will use
scriptscript size for a subscript on a subscript or for a superscript on
a scriptsize numerator.
\endconcept

\concept shrink

See \conceptcit{glue}.
\endconcept

\concept space

You can cause \TeX\ to put \defterm{space} between two items in 
several~ways: 

\olist
^^{end of line}
\li You can write something that \TeX\ treats as a space
\refterm{token}: one or more blank characters, the end of a line (the
end-of-line character acts like a space), or any \refterm{command} that
expands into a space token.  \TeX\ generally treats several consecutive
spaces as equivalent to a single one, including the case where the
spaces include a single end-of-line.  (An empty line
indicates the end of a paragraph; it
causes \TeX\ to generate a |\par| token.)
^^|\par//from empty line|
\TeX\ adjusts the size of
this kind of space to suit the length required by the context.

^^{glue//creating space with}
\li You can write a skip command that produces the glue
you specify in the command.  The glue can
\refterm{stretch} or \refterm{shrink},
producing more or less space.  You can have vertical glue as
well as horizontal glue.  Glue disappears whenever it is next to a
line or page break.

^^{kerns//creating space with}
\li You can write a \refterm{kern}.  A kern produces a fixed amount of
space that does not stretch or shrink and does not disappear at a line
or page break (unless it is immediately followed by glue).  The most
common use of a kern is to establish a fixed spatial relationship
between two adjacent \refterm{boxes}.
\endolist

Glue and kerns can have negative values.  Negative glue or a negative kern
between adjacent items brings those items closer together.
\endconcept


\concept stretch

See \conceptcit{glue}.
\endconcept


\conceptindex{struts}
\concept strut

{\tighten
A \defterm{strut} is an invisible \refterm{box}
^^{boxes//invisible}
whose width is zero and whose height and depth are slightly more than
those of a ``normal''
line of type in the context.  Struts are useful for obtaining
uniform vertical spacing when \TeX's
usual line spacing is disabled, e.g., within a math formula
or within a horizontal alignment where you've specified ^|\offinterlineskip|.
Because a strut is taller and deeper than everything else on its line,
it determines the height and depth of the line.
You can produce a strut with
the ^|\strut| command \ctsref{\strut} or the ^|\mathstrut| command
\ctsref\mathstrut.
You can use |\strut| anywhere, but you can only use |\mathstrut| when
\TeX\ is in math \refterm{mode}.  A strut in \plainTeX\ has height 8.5\pt\ and
depth 3.5\pt, while a math strut has the height and depth of a left
parenthesis in the current \refterm{style} (so it's smaller for
subscripts and superscripts).
\par}

Here's an example showing how you might use a strut:
\csdisplay
\vbox{\hsize = 3in \raggedright
   \strut Here is the first of two paragraphs that we're
   setting in a much narrower line length.\strut}
\vbox{\hsize = 3in \raggedright
   \strut Here is the second of two paragraphs that we're
   setting in a much narrower line length.\strut}
|
This input yields:
\display{\vbox{
\vbox{\hsize = 3in \raggedright
\strut Here is the first of two paragraphs that we're setting
in a much narrower line length.\strut}
\vbox{\hsize = 3in \raggedright
\strut Here is the second of two paragraphs that we're setting
in a much narrower line length.\strut}
}}
\noindent
Without the struts the \refterm{vboxes:vbox} would be too close 
together.  Similarly, in the formula:
\csdisplay
$\overline{x\mathstrut} \otimes \overline{t\mathstrut}$
|
the math struts cause both bars to be set at the same height even
though the `$x$' and the `$t$' have different heights:
\display{
$\overline{x\mathstrut} \otimes \overline{t\mathstrut}$
}
\vskip -\belowdisplayskip
\endconcept
\nobreak

\conceptindex{styles}
\concept {style} 

Material in a math formula is set in one of eight \defterm{styles},
depending on the context.  Knowing about styles can be useful if you want to
set part of a formula in a different size of type than the one
that \TeX\ has chosen according to its usual rules.

\eject
The four primary styles are:

\vdisplay{%
\halign{\refterm{# style}\hfil&\hskip .25in(for #)\hfil\cr
display&formulas displayed on a line by themselves\cr
text&formulas embedded in ordinary text\cr
script&superscripts and subscripts\cr
scriptscript&superscripts on superscripts, etc.\cr
}}

The other four styles are so-called ^{cramped variants}.  In these
variants superscripts aren't raised as high as usual, and so the formula
needs less vertical space than it otherwise would.  See
\knuth{pages~140--141} for the details of how \TeX\ selects the style.

\TeX\ chooses a size of type according to the style:

\ulist\compact
^^{display style}^^{text style}
\li Display style and text style are set in \refterm{text size}, like
`$\rm this$'.

^^{script style}
\li Script style is set in \refterm{script size}, like `$\scriptstyle
\rm this$'.

^^{scriptscript style}
\li Scriptscript style is set in \refterm{scriptscript size}, like
`$\scriptscriptstyle \rm this$'.
\endulist

See \conceptcit{family} for more information about these three sizes.

\TeX\ doesn't have a ``scriptscriptscript'' style because such a style
would usually have to be set in a size of type too small to read.  \TeX\
therefore sets third-order subscripts, superscripts, etc., using the
scriptscript style.

Once in a while you may find that \TeX\ has set a formula in a different style
than the one you'd prefer.  You can override \TeX's choice with the
^|\textstyle|, ^|\displaystyle|, ^|\scriptstyle|, and ^|\scriptscriptstyle|
commands \ctsref{\textstyle}.
\endconcept

\concept {\TeXMeX}

(a)~A variant of \TeX\  used for mathematical typesetting in
Central American countries.
(b)~A spicy cuisine favored by the \TeX\-ni\-cians of ^{El Paso}. 
\endconcept


\concept {text math}

We use the term \defterm{text math} to refer to a math formula set within a
line of text, i.e., enclosed in |$|'s.
\ttidxref{$}
\TeX\ sets text math in text math \refterm{mode}.
\endconcept


\concept {text size}

\defterm{Text size} describes the largest of the three related
\refterm{fonts:font} in a \refterm{family}.
^^{family//text size in}
\TeX\ uses text size for ordinary symbols appearing in 
\refterm{math mode}.
\endconcept


\conceptindex{tokens}
\concept token

A \defterm{token} is either a single character tagged with a
\refterm{category code}, or a \refterm{control sequence}.  \TeX\ reads
characters from a file using its eyes \seeconcept{\anatomy}
and groups the characters into tokens using its mouth.  When a token
reaches \TeX's stomach, \TeX\ interprets it as a \refterm{command}
unless it's part of an argument of a preceding command.
\endconcept


\conceptindex{units of measure}
\concept {unit of measure}

See \conceptcit{dimension}.
\endconcept

\conceptindex{vboxes}
\concept vbox

^^{vertical lists//vboxes formed from}
A \defterm{vbox} (vertical box) is a \refterm{box} that \TeX\ constructs
by placing the items of a \refterm{vertical list} one after another, top
to bottom.  A vbox, taken as a unit, is neither inherently horizontal
nor inherently vertical, i.e., it can appear as an item of either a
vertical list or a \refterm{horizontal list}.  You can construct a vbox
with the ^|\vbox| or the ^|\vtop| command
\ctsref{\vtop}.  The difference is that for |\vbox|,
the \refterm{reference point}
of the constructed vbox is derived from that of the last (and
usually bottommost) constituent list item, but for |\vtop|, it's that of the
first (and usually topmost) constituent list item.
\endconcept


\conceptindex{vertical lists}
\concept{vertical list}

A \defterm{vertical list} is a list of items 
that \TeX\ has produced while it is
in one of its vertical modes, i.e.,
assembling either a
\refterm{vbox} or a page.  See ``vertical mode'' below.

\endconcept


\concept{vertical mode}

^^{vboxes//vertical mode for} When \TeX\ is assembling either a
\refterm{vbox} or the main vertical list from which pages are derived,
it is in one of two \defterm{vertical modes}: ^{ordinary
vertical mode} for assembling the main vertical list, and ^{internal
vertical mode} for assembling vboxes.  Whenever \TeX\ is in a vertical mode
its stomach \seeconcept{\anatomy} is constructing a \refterm{vertical
list} of items (boxes, glue, penalties, etc.).
\TeX\ typesets the items in the list
one below another, top to bottom.

A vertical list can't contain any items produced by 
inherently horizontal commands, e.g.,
^^{vertical lists//can't contain horizontal commands}
|\hskip| or an ordinary (nonspace) character.
\footnote{\TeX\ \emph{ignores} any space characters
that it encounters while it's in a vertical mode.}

\ulist
\li If \TeX\ is  assembling a vertical list in ordinary vertical mode and
encounters an inherently horizontal command, it switches to ordinary
\refterm{horizontal mode}. 
\li If \TeX\ is  assembling a vertical list in internal vertical mode and
encounters an inherently horizontal command, it complains.
\endulist

Two commands that you might at first think are inherently vertical are
in fact inherently horizontal: |\valign| \ctsref{\valign} and |\vrule|
\ctsref{\vrule}.
^^|\valign//inherently horizontal|
^^|\vrule//inherently horizontal|
See \knuth{page~283} for a list of the
inherently horizontal commands.

It's particularly important to be aware that \TeX\ considers an ordinary
character other than a space character to be inherently horizontal.  If
\TeX\ suddenly starts a new paragraph when you weren't expecting it,
a likely cause is a
character that \TeX\ encountered while in vertical mode.
You can convince \TeX\
not to treat that character as inherently horizontal by enclosing it in
an \refterm{hbox} since the |\hbox| command, despite its name, is
neither inherently horizontal nor inherently vertical.
\endconcept


\concept whatsit

A \defterm{whatsit} is an item of information that 
tells \TeX\ to carry out some action
that doesn't fit into its ordinary scheme of things.
A whatsit can appear in a horizontal or vertical list, just like a box
or a glue item.
\TeX\ typesets a whatsit
as a \refterm{box} having zero width, height, and depth---in other
words, a box that contains nothing and occupies no space.

Three sorts of whatsits are built into \TeX: 
\ulist
\li The |\openout|, |\closeout|, and |\write| commands
(\p\xrefn{\openout})
% (2nd) removed \xref to \write, since it's on the same page
produce a whatsit for operating on an output file.
^^|\openout//whatsit produced by|
^^|\write//whatsit produced by|
^^|\closeout//whatsit produced by|
\TeX\ postpones the operation until it next ships out a page
to the {\dvifile}
^^{\dvifile//whatsits in}
(unless the operation is preceded by ^|\immediate|).
\TeX\ uses a whatsit for these commands because they don't have anything
to do with what it's typesetting when it encounters them.
\li The ^|\special| command \ctsref{\special} tells \TeX\ to
insert certain text directly into the \dvifile.
As with the |\write| command, \TeX\ postpones the insertion
until it next ships out a page to the {\dvifile}.
^^{\dvifile//material inserted by \b\tt\\special\e}
A typical use of |\special| would be to 
name a graphics file that the device driver should incorporate into
your final output.
\li When you change languages with the ^|\language| or ^|\setlanguage|
commands \ctsref{\language},
\TeX\ inserts a whatsit that instructs it to use a
certain set of hyphenation rules later on when it's breaking a paragraph
into lines.
\endulist
\noindent
A particular implementation of \TeX\ may provide additional whatsits.
\endconcept


\concept width

^^{boxes//width of}
The \defterm{width} of a \refterm{box} is the amount of horizontal space
that it occupies, i.e., the distance from its left edge to its
right edge.  The typeset material in a box can be wider than the box itself.
\endconcept

\endconcepts

\endchapter
\byebye
