Before talking about LATEX one should understand TEX internals a
little more. The basic TEX program contains only a few primitive
commands and is written at too low a level to be generally useful. However,
you can preload a set of macros--more complex commands built out of TEX
primitives. One way to load these is to have them in a separate file, say
macros.tex and then to write \input macros.tex as the first
line of your document. This can be very slow if you have a lot of macros
because TEX has to parse all of them and load them into memory. To get
around this you can dump a memory image of your macros as a format file.
TEX can then load this in each time very quickly--it just writes the
file straight to memory. The default format is Plain TEX written by
Donald Knuth during the development of TEX .
Plain TEX has enough commands to be able to use TEX --that is what our first document used--but it is not very user-friendly. There are many other formats available, the most popular of which is LATEX (now called LATEX2e ) written by Leslie Lamport. It is on this that I shall concentrate.
TEX will automatically load a format on startup, depending on how you call the program. Typically, tex will run the default format, latex will run LATEX2e and there may be other commands to load other formats. An alternate way of doing this is to specify the format when you run TEX :
tex &format \input file.tex
but you have to be careful to protect the `&' and the `
rob@random:~/$ latex myfile.tex
rob@random:~/$ tex \&latex \\input myfile.tex
\input package to load extra
packages
There are two main ideas behind LATEX . The first is to provide user-friendly wrappers around standard Plain TEX commands. For example the commands used in TEX and LATEX to typeset the matrix below are shown in Figure 7.
But suppose you want to format the matrix a little differently, e.g. align everything on the right hand side. Figure 8 shows the new matrix and its LATEX commands, while Figure 9 shows the corresponding TEX .
The point is that in LATEX you can usually change the appearance of an environment by changing some parameter, while in TEX one must add extra commands.
The main idea is to free you from formatting concerns. TEX knows how to typset text correctly, but LATEX knows how to format a whole document. LATEX understands the form that a paper, article, report or book should take, provides you with commands to fill in things like chapter titles and section names, and then lets you concentrate on the content. This is the opposite of a WYSIWYG word-processor where you must be constantly aware of what your document looks like.
The LATEX paradigm is that a document is broken into logical sectional units--chapter, section, subsection, etc. Within any unit you may produce extra formatting by using a special environment. The default environment is a paragraph, but anything else may be used with a pair:
\begin{environment} ... \end{environment}
For example the list
\begin{itemize}
\item Chapter
\item Section
\item Subsection
\end{itemize}
The first line in your file must be
\documentclass[options]{class}
\begin{document} ... \end{document}
If we create a file perfect2.tex containing the text below and then use the command latex perfect2.tex to run LATEX , then it will produce the output shown on the following page.
\documentclass[12pt]{article}
\begin{document}
\title{Unsolved Problems}
\author{Robert P. Judd}
\maketitle
\section{Odd Perfect Numbers}
A number is said to be \textbf{perfect} if it is the
sum of its divsors. 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 \textit{odd} perfect numbers is an
open question.
\end{document}