TeX is a typesetting system for producing professional
quality scientific documents (books, articles, reports), especially those
containing a lot of mathematical symbols.
The author of TeX is Stanford University computer scientist Donald Knuth. TeX comes from the Greek word tec which means both art and technology.
Knuth designed it because he was unhappy about how publishers
were typesetting his books and articles. In so doing he studied a lot about
how traditional typesetting and printing is carried out and built a lot
of expert knowledge into the program.
TeX is pronounced to rhyme with "belch" and not as in "Tex-Mex" (!!!)
TeX consists of both a language and a program (really a series of programs). The definitive version of the TeX language and program were released by Knuth in 1983. The series of books Computers and Typesetting by Knuth (1986) include
The TeX program is in the public domain (Knuth has apparently
made a lot of money selling his TeX books). However, it is difficult to
implement (there are literally hundreds of different files needed). A good
implementation is a great help. Now both commercial and free implementations
are available.
For example, in the 1980's the American Mathematical Society (AMS) released AMS-TeX which had several improvements over "plain" TeX especially in handling very complex mathematical formulas and a special set of additional fonts. This was developed by Michael Spivak.
Around the same time (1986) Leslie Lamport, a computer scientist at Digital Equipment released LaTeX (and The LaTeX Book). LaTeX included many stylistic innovations including the crucial feature of automatic numbering of theorems and equations.
Circa 1990 LaTeX (version 2.09) had become the de-facto standard version in most fields, except that some mathematicians continued to use AMS-TeX.
A wish list for TeX users included LaTeX version 3 and a combination of LaTeX and AMS-TeX.
LaTeX-2e (i.e., not laTeX 3) was released in 1994. It is the result of a systematic improvement of how LaTex operates internally. At around the same time the AMS releases AMS-LaTeX, which runs as a package within LaTeX-2e.
For most purposes these days LaTeX-2e or AMS-LaTeX should be used for most purposes (although "plain" TeX can still be useful).
Some other useful programs are:
Basically you type an ascii file with the extension ".tex", which describes your document.
As in HTML you do not worry about formatting.
The visual implications of these logical relations is contained in the style file parameters. This permits you to, say print your paper one way, but when you send it to the printer, they can change the style to fit the style of their publication.
In HTML the markup os accomplished by surrounding an item by tags. For example, to emphasize a certain line of text in HTML you type:
<EM> This is emphasized. </EM>
to achieve the effect
This is emphasized.
The browser decides how to set emphasized text (usually italics).
If you want to guarantee italics you can type
<IT> This will be in italics! </IT>
and get
This will be in italics!
However, this would be a slight violation of the principle logical document design because we are saying what the text should look like.
Logical design is a great idea in theory but it can be a pain in practice, and HTML has been moving away from a strict interpretation of it for years, especially as the web becomes more commercial and .com's want complete control of what their web sites look like.
Now let's look at the same idea in LaTeX. To emphasize a block of text we type
{\em Emphsize this}
to get
Emphasize this!
(usually italics). But we can also ask explicitly for italics:
{\it I want Italics!}
Note the differences with HTML. In stead of tags TeX uses control characters which are any contiguous sequence of characters starting with a backslash "\". The scope of the control characters (in this case) is controlled by curly brackets: "{" and "}".
Some other font controls are "\bf" for boldface, "\rm" for roman, "\tt" for teletype.
In TeX & LaTeX the big thing is mathematical formulas.
In plain TeX inline math formulas are set between two "$"s:
An inline equation $x^2-x-1=0$ appears in the line.
Gives (approximately)
An inline equation x2-x-1=0 appears in the line.
Equations can also be displayed:
A displayed equation $$x^2-x-1=0$$ sits by itself, centered on its own line.
Gives (approximately)
A displayed equation
Both of these plain TeX conventions violate the custom that delimiters or tags should come in left and right pairs.
LaTeX uses \( x^2-x-1=0 \) for inline and \[ x^2-x-1=0 \] for display.
Note that spaces can be inserted anywhere in TeX (they don't matter) except in the middle of control characters, so
\[ x^2 - x -1 = 0 \] is ok and might be more readable, but \ [ x^2-x-2=0] \ is not.
For what it's worth, I don't use these! In LaTeX I fall back on $x^2-x-1=0$ for inline equations and use a LaTeX environment:
\begin{equation}
x^2-x-1=0
\end{equation}
for display. More complicated environments allow alignment of multi-line equations, matrices, etc.
A few more words on math mode (the mode in which equations are typed).
Greek letters have control characters that are typed out:
For all $\epsilon>0$ there exists $\delta>0$ so that if $|x-y|<\delta$, then $|f(x)-f(y)|<\epsilon$.
Subscripts and superscripts use "_" and "^" and can be compounded with brackets.
Given a sequence $x_1, x_2, x_3, \dots$ we pass to a sub sequence $x_{i_1}, x_{i_2}, x_{i_3}, \dots$.
Here is a final example
\begin{equation}
\frac{1}{\sqrt{2\pi}}\, \int_{-\infty}^\infty
e^{-x^2}\,dx=1
\end{equation}
A last comment: LaTeX requires (at least) a few lines special lines of code at the beginning and end of any file:
\documentclass{article}
\begin{document}
Put your text here...
\end{document}
You can see a TeX
document containing all the formulas described here. The resulting
output
is also shown (in a pdf form).
>tex file
Assuming there are no errors (a big assumption), you will get a file "file.dvi". The "dvi" stands for "device independent". You can open and print this by using the dvi-viewer "yap". You can also convert it to a postscript file using
>dvips file
(you get file.ps).