|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T U
Length: 12494 (0x30ce)
Types: TextFile
Notes: Uncompressed file
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
└─⟦c319c2751⟧ »unix3.0/TeX3.0.tar.Z«
└─⟦036c765ac⟧
└─⟦69eeda56b⟧ »TeX3.0/TeXcontrib/urban/textroff/mathmode.tex.Z«
└─⟦060c9c824⟧ Bits:30007080 DKUUG TeX 2/12/89
└─⟦69eeda56b⟧ »./tex82/TeXcontrib/urban/textroff/mathmode.tex.Z«
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
└─⟦63303ae94⟧ »unix3.14/TeX3.14.tar.Z«
└─⟦c58930e5c⟧
└─⟦69eeda56b⟧ »TeX3.14/TeXcontrib/urban/textroff/mathmode.tex.Z«
└─⟦this⟧
\Section{Setting Mathematics}
\def\Eqn/{{\it eqn\/}}
Many people find that the most useful adjunct to \Troff/ is
the program \Eqn/, which provides a ``pronounceable''
way to describe mathematical equations for typesetting. \TeX\ provides
a built-in {\sl mathematics mode\/} in which the meanings
of the letters and control sequences are changed to allow
easier equation settings.
Actually, there are two forms of mathematics mode in
\TeX: {\sl text\/} math mode, and {\sl display\/} math mode.
Text math mode is used for the in-line expressions specified
by the |delim| feature of \Eqn/. It is delimited by
single dollar signs. For example, one can say something
like
\nobreak\begintt
Let $x$ be the sum of $y$ and $z/2$.
\endtt
in the middle of a paragraph, and produce something like
`Let $x$ be the sum of $y$ and $z/2$.' Note that
math mode sets letters in italics but numerals in
roman font.
Display math mode is for setting equations between paragraphs
just as the |.EQ| and |.EN| macros of \Eqn/ do. The display
math delimiters are double dollar signs, |$$|. For example,
to display the equation $$x+5$$ this document includes
a line that says:
\nobreak
\begintt
to display the equation $$x+5$$ this document includes
\endtt
Note that display math mode automatically centers the
display on the page and provides the extra vertical spacing
around it.
\TeX's math mode contains a great deal of built-in knowledge
about equation spacing, and therefore {\sl ignores\/} spaces
that occur between the dollar signs (just as \Eqn/
does). For example |$ x $| has
the same effect as |$x$|. You can always force extra space
by using |\quad|, |\|\] (escape-space),
or a glue specification; there are also
special control sequences for thinner spaces.
\SubSection{Greek Letters}
Unlike \Eqn/, which converts words like `omega' into the
corresponding Greek letters, \TeX\ requires control words
to produce these.
While this may, at first, seem a nuisance, one is freed
from having to worry about `reserved words' in \TeX.
For example, to produce
$$x=2\pi\int\sin(\omega t)dt$$
one would type
|$$x=2\pi\int\sin(\omega t)dt$$|. Upper-case Greek letters
(which are pronounced like |GAMMA| in \Eqn/) have names
like |\Gamma| in \TeX. Math mode provides a host of other
math characters like |\infty| for `$\infty$';
Appendix~A lists several of these.
\SubSection{Subscripts and Superscripts}
\TeX\ math mode provides a simple method of superscripting
and subscripting, using the special characters |^| and |_|,
respectively. For example, to set `$x^2$' one types |$x^2$|.
Similarly, `$\alpha_0$' is pronounced |$\alpha_0$|. These
characters normally apply only to the next single character.
If you want more things subscripted or superscripted, you
can group them. For example, `$x^{y_2}$' is typed as
|$x^{y_2}$|. However, unlike \Eqn/, \TeX\ considers
a construct like
|$x^y^z$| illegal; you should specify |$x^{y^z}$| or
|$x^{yz}$|, depending on what is meant.
One can, however, specify |$x^2_3$| in order to obtain
`$x^2_3$'; |$x_3^2$| is equivalent. Notice that
simultaneous su$\rm_b^{per\kern-1pt}$scripts are stacked
over one another. A special character `$\prime$', designed specifically
for being shrunk and raised for superscripting, is designated
by the control word |\prime|. For example, one might
refer to |$f^\prime(x)$| to set `$f^\prime(x)$'. Plain \TeX\ provides
a convenient abbreviation: a single quote. For example,
you could also say |$f'(x)$| (for `$f'(x)$')
or even |$f'''(x)$| for `$f'''(x)$'.
\SubSection{Fractions}
\TeX\ fractions are similar to \Eqn/'s treatment. One can
type |$a/b$| to obtain `$a/b$,' but if one wants an
equation like $${x+y^2}\over{k+1}$$ one may type
`|$${x+y^2}\over{k+1}$$|'. This can be taken to excess; Knuth
warns one against expressions like |$$a\over{b\over 2}$$|,
which produces the formula $$a\over{b\over 2}$$ This looks
fairly awful; the recommended alternative is |$$a\over{b/2}$$|,
which produces
$$a\over{b/2}$$
Plain \TeX\ also provides an operator |\choose|
for producing binomial coefficients such as $n\choose2$, which
is typed as |$n\choose 2$|.
\SubSection{Square Roots}
The control squence |\sqrt| produces square roots.
For example |$\sqrt2$| produces `$\sqrt2$' and
\begintt
$$\sqrt{x^3+\sqrt\alpha}$$
\endtt
produces
$$\sqrt{x^3+\sqrt\alpha}$$
You can produce other roots using |\root| and |\of|. For
example, |$$\root 3 \of {x+y}$$| produces $$\root 3 \of {x+y}$$
\TeX\ is able to handle fairly tall formulas without getting
too ugly. For example, the input
\nobreak\begintt
$$\sqrt{a^2\over{b_2}}$$
\endtt
produces
$$\sqrt{a^2\over{b_2}}$$ which is
substantially better than the ugly example on page~4
of the \Eqn/ manual. A similar method produces
lines below or above formulas: |$\overline{x+y}$| produces
`$\overline{x+y}$.'
\SubSection{Large Operators}
{\raggedright
Plain \TeX\ provides {\sl large operators\/} like
$\sum$, $\int$ and $\prod$, which
produce larger symbols in display math mode than in text.
For example |$\sum x_n$| produces $\sum x_n$, but
|$$\sum x_n$$| produces $$\sum x_n$$
If one wishes to add ``limits'' to such operators, they
can be typed like subscripts. For example,\hfil\break
|$$\sum_{n=1} ^m x_n$$| produces $$\sum_{n=1}^m x_n$$
The |\int| operator, $\int$, normally has its limits placed
to the sides of the operator. For example, |$$\int _0 ^{\infty}$$|
produces
$$\int_0^{\infty}$$ If one wishes to change this convention, one
can type `|\limits|' directly after the |\int| operator. For
example, |$$\int\limits_0^{\pi\over 2}$$| yields $$\int\limits_0^{\pi\over 2}$$
Certain defined control
sequences in plain \TeX\ also accept limits. For example,
$$\lim_{n\to\infty}x_n=0$$
is produced by |$$\lim_{n\to\infty}x_n=0$$|.
}
\SubSection{Fonts}
Normally, text in math mode is set in math italic (similar, but not
identical to text italic). Sometimes, one wants roman
type as part of a formula, especially with such mathematical functions
as `log' and `sin'. Plain \TeX\ defines several control sequences
such as |\sin|, |\ln|, and |\lim| which always are set in roman
type. You can also switch explicitly to roman by typing |\rm|.
For example, `$x^3+{\rm lower\ order\ terms}$' can be set by
typing |$x^3+{\rm lower\ order\ terms}$|. Notice that spaces
had to be explicitly inserted by preceding them with the
backslash, because \TeX\ ignores spaces in math mode.
Bold face can also be used. For example, |$\bf a+b=\Phi_m$|
produces `$\bf a+b=\Phi_m$'. Plain \TeX\ arranges matters
so that the |\bf| control sequence only affects alphabetic
characters when in mathematics mode. There is also a `calligraphic'
font for use with upper-case (and {\sl only\/} upper-case) letters
in math mode. |$\cal EXAMPLE$| produces `$\cal EXAMPLE$'. Finally,
|\it|, |\sl|, and |\tt| can be used, but cannot be produced in
subscript size.
\SubSection{Accents}
Plain \TeX\ defines eight control sequences for placing
accents over letters in mathematics mode:
\nobreak\vskip 8pt
\leftline{\vbox{\halign{\hskip .5in\tt\$\\# a\$&\hskip 1in$#$\cr
hat&\hat a\cr
check&\check a\cr
tilde&\tilde a\cr
dot&\dot a\cr
ddot&\ddot a\cr
breve&\breve a\cr
bar&\bar a\cr
vec&\vec a\cr}
}}
Note that the |dyad| accent of \Eqn/ is not present in plain
\TeX. Also
note that |\underline| and |\overline| can be used to place
a bar over or under any formula.
\SubSection{Alignments}
The |mark| and |lineup| constructs of \Eqn/ are used to
align equations. In \TeX, this can be done using the powerful
|\halign| mechanism as described in the previous section. However,
plain \TeX\ also provides some special-purpose alignment macros
for doing some of the more common operations without resorting
to |\halign|.
The most common use of aligned formulas is in multi-line
displays that should be lined up by their `=' signs.
Plain \TeX\ provides the |\eqalign| macro for this purpose.
For
example, the example (that can't be done with |mark|) in the
\Eqn/ manual:
$$\eqalign{x&=1\cr x+y&=z\cr}$$ was typed as
\nobreak\begintt
$$\eqalign {
x & =1 \cr
x+y & = z\cr
}$$
\endtt
The right-hand side can start with an equals-sign or any other
symbol. For example, one might wish to say something like:
$$\eqalign {
x+y+z & < 5\cr
z & = y/42\cr
y\sin z & > x\log z\cr
}$$
with the equality and inequality symbols aligned.
This can be typed as
\begintt
$$\eqalign {
x+y+z & < 5\cr
z & = y/42\cr
y\sin z & > x\log z\cr
}$$
\endtt
Another type of aligned display is something like
$$f(x)=\cases{
x,& for $x\ge 0$;\cr
0,& otherwise.\cr}$$
For this sort of display, the special macro |\cases| is defined.
This example was typed as
\nobreak\begintt
$$f(x)=\cases{
x,& for $x\ge 0$;\cr
0,& otherwise.\cr}$$
\endtt
Note that the first column is implicitly in mathematics mode, but
the second column is {\sl not\/}. For example, the `$x\ge 0$'
of the first line had to be set explicitly in math mode. The
|\cases| macro automatically typesets its own `$\{$' in the
appropriate size.
Finally, matrices can be set up using the |\matrix| alignment
macro. For example, a neat array like
$$\matrix{
x_i & x^2 \cr
y_i & y^2 \cr
}$$
can be set up by typing
\begintt
$$\matrix{
x_i & x^2 \cr
y_i & y^2 \cr
}$$
\endtt
To set the array with big parentheses around it, |\pmatrix|
can be used instead of |\matrix|, to produce
$$\pmatrix{
x_i & x^2 \cr
y_i & y^2 \cr
}$$
Of course, there are other ways of typing arbitrary brackets,
as described in the next section.
\SubSection{Big Brackets, Etc.}
Plain \TeX\ provides an assortment of brackets and delimiters
that can be used for formulas. The obvious ones are the
parentheses and brackets; one can also use |\{| and |\}| for
braces in math mode. In addition, there are
|$\lfloor$| for `$\lfloor$', |$\lceil$| for `$\lceil$',
and |$\langle$| for `$\langle$'. The right-hand versions
are |$\rfloor$|, |$\rceil$|, and |$\rangle$|.
One can also use the vertical bar, \vrt, as a delimeter
(e.g. to signify absolute value).
Sometimes one wishes
to get a larger version of these symbols. To do this, precede them
by `|\bigl|' for the left side and `|\bigr|' for the right. This
can make formulas easier to read. For example,
\begintt
|$$\bigl(x-s(x)\bigr)\bigl(y-s(y)\bigr)$$|
\endtt
produces
$$\bigl(x-s(x)\bigr)\bigl(y-s(y)\bigr)$$
In \Eqn/, there is a generalized mechanism that produces brackets
big enough for whatever they enclose, using the keywords |left| and
|right|. The mechanism in \TeX\ is quite similar. For example,
the example on page~6 of the \Eqn/ manual,
$$\left\{a\over b + 1\right\}
=\left(c\over d \right)
+\left[e\right]
$$
is produced by the input
\begintt
$$\left\{a\over b + 1\right\}
=\left(c\over d \right)
+\left[e\right]
$$
\endtt
The |\left| and |\right| delimiters {\sl must\/} pair up with one
another, just as braces do in \TeX\ groups. However, one can
use a period (`|.|') as a null delimiter in unbalanced groups.
For example,
\begintt
$$x=\left\{y\over 3\right.$$
\endtt
produces
$$x=\left\{y\over 3\right.$$
The `|\right.|' sequence outputs nothing, but closes the
group begun by the |\left\{| sequence.
\SubSection {Displayed Text}
Display math mode can also be used to center and set off
textual material or alignments. To do this, simply place
the material in a box using |\hbox| or |\vbox|. For example,
\nobreak
\begintt
$$\hbox{Display Text}$$
\endtt
produces
$$\hbox{Display Text}$$
Notice that the text occurs in the regular text font (ten-point
Roman) rather than math italics.
An even more practical use of this technique is for alignments.
A table can be centered easily.
\begintt
$$\vbox
{\halign
{\tt#\hfil & \quad #\hfil \cr
\bf\hfil Name & \bf\hfil Supplier\cr
\noalign {\smallskip\hrule\smallskip}
\TeX & University of Washington\cr
TROFF & Bell Laboratories\cr
SCRIBE & Unilogic, Ltd.\cr
DSR & DEC (VMS Only)\cr
}}$$
\endtt
produces
$$\vbox
{\halign
{\tt#\hfil & \quad #\hfil \cr
\bf\hfil Name & \bf\hfil Supplier\cr
\noalign {\smallskip\hrule\smallskip}
\TeX & University of Washington\cr
TROFF & Bell Laboratories\cr
SCRIBE & Unilogic, Ltd.\cr
DSR & DEC (VMS Only)\cr
}}$$
complete with the spacing that separates it from the surrounding
textual material.
\SubSection {More Reading}
This section has outlined some of the more straightforward uses of
math mode. There are many other facilities, as described in
``{\sl The \TeX book\/}''. Consult that volume for
additional ideas.