As we have already noted there are several steps needed to create a
document in TEX .
We will now create a simple TEX document, by entering in the following
text to a file called perfect.tex.
\parskip=\baselineskip \parindent=0pt \hsize=5in
\hoffset=.75in
\centerline{\bf Unsolved Problems} \vskip 15pt
A number is said to be {\bf perfect} if it is the
sum of its divisors. For example, $6$ is perfect
because $1+2+3=6$, and $1$, $2$ and $3$ are the
only numbers that divide evenly into $6$ (apart
from $6$ itself).
It has been shown that all even perfect numbers
have the form $$2^{p-1}(2^p-1)$$ where $p$ and $q$
are both prime.
The existence of {\it odd\/} perfect numbers is an
open question. \bye
|
Save the file and run TEX on it with tex perfect.tex:
rob@random:~$ tex perfect.tex This is TeX, Version 3.14159 (Web2C 7.3) (perfect.tex [1] ) Output written on perfect.dvi (1 page, 892 bytes). Transcript written on perfect.log. rob@random:~$The output file is called perfect.dvi. We may preview this file by running the command xdvi perfect.dvi:
Commands (or control sequences) are usually a backslash followed by a
sequence of letters. They are case sensitive, e.g. \vskip. Control
sequences end with the first non-letter. Thus \vskip2in says skip 2
inches vertically.
Arguments to a command may be enclosed in braces to make it clear what the argument is--if the argument has spaces, then you will definitely need braces. For example in
\centerline{\bf Unsolved Problems},
the argument to \centerline is \bf Unsolved Problems.
Braces are used to enclose an argument, but also to delimit the scope of a
command. For example \bf makes all the following text bold. If you
only want a small amount of text bold, then you enclose the text in braces:
{\bf perfect}
TEX has the following special or reserved characters:
| Symbol | Meaning | Typeset with |
| # | Parameter definition | \# |
| $ | Toggles math mode | \$ |
| % | A comment | \% |
| & | Column separator | \& |
| ~ | Unbreakable space or accent | \~{\ } |
| ^ | Superscript or accent | \^{\ } |
| _ | Subscript | \_ |
|
|
Begins a control sequence | $\backslash$ |
| { | Begin group | \{ |
| } | End group | \} |
|
|
em-dash (|) | $|$ |
|
|
Upside down ! (<) | $<$ |
|
|
Upside down ? (>) | $>$ |
" |
No meaning | \verb+"+ |
| `` | Open double quote | `` |
| '' | Close double quote | '' |
Mathematics is written in single dollar signs for inline, and double
dollar signs for displayed math: $x^2+y^2=1$ gives
,
while $$x^2+y^2=1$$ gives
TEX can produce a wide range of accents and other spceial characters used in text. A few examples of these are given below.
| Character | Typeset | Appearance |
| tilde | \~n |
cañon |
| acute | \'e |
résumé |
| circumflex | \^o |
l'Hôpital |
| grave | \`a |
á la mode |
| umlaut | \"e |
Noël |
| cedilla | \c c |
garçon (gar\c con) |
\ae \AE |
Ægean, ægean (\AE gean) |
|
\ss |
Weierstraß | |
\AA |
Ångstrom (\AA ngstrom) |
|
<Si! |
<Si! | |
>Que? |
>Que? |
anti-alias5--10\ldots
` and
' characters: ``He said, `Go away!' so I left.''