28-09-2013, 03:41 PM
LaTeX Tutorial
LaTeX Tutorial.pdf (Size: 221 KB / Downloads: 20)
Introduction to LaTeX
LaTeX is a family of programs designed to produce publication-quality typeset
documents. It is particularly strong when working with mathematical symbols.
The history of LaTeX begins with a program called TEX. In 1978, a computer
scientist by the name of Donald Knuth grew frustrated with the mistakes that
his publishers made in typesetting his work. He decided to create a typesetting
program that everyone could easily use to typeset documents, particularly those
that include formulae, and made it freely available. The result is TEX.
Knuth’s product is an immensely powerful program, but one that does focus
very much on small details. A mathematician and computer scientist by the
name of Leslie Lamport wrote a variant of TEX called LaTeX that focuses on
document structure rather than such details.
Error Messages
LaTeX will tell you when it figures out that something is wrong. Often the
actual error occurs earlier in your file.
A common error is not to close braces for a command. Another one that occurs
frequently is to use math commands outside of math mode (described later).
Since LaTeX will stop after any \end{document} command, a good strategy
for finding errors is to insert \end{document} temporarily earlier in the file to
see if the error is above its location.
Typing LaTeX Commands
For this tutorial, you will occasionally find yourself having to type LaTeX com-
mands as part of your text. How do you do that without LaTeX taking them
seriously and following them?
Surround any text that you want printed as is with a \begin{verbatim} and
an \end{verbatim} command.
Creating a Title Page
The title, author, and date of your document are information that various LaTeX
commands can make use of, if you provide it. It is a good habit to get into to
provide this information in the preamble of your document. (Remember that
the preamble refers to any commands between the \documentclass command
and the \begin{document} command.)
Cross-References
If you wish to have cross-references in a document with numbered sections, use
\label{name} to label the point in your document with some mnemonic, and
Section \ref{name} to refer to that point. \ref{name} will be replaced by
the number of the section containing the corresponding \label command. As
with your bibliography citations, you will need to run LaTeX twice to generate
these references.
Text in Math Displays
There will be times when you want to include Roman, i.e., non-italicized words
amongst your mathematical symbols. The font isn’t the only problem; spacing
is different between letters in a word and variables in a formula. Use the com-
mand \mbox{your text here} to include short phrases in a formula. (If your
phrase isn’t short, then you should consider embedding your formula in a text
paragraph instead of your text in a formula paragraph.)
Special Headers
A header is the text automatically included at the top of each document. If you
use \pagestyle{myheadings}, then you will need some way to indicate what
your heading is. The command \markright{Your Header Text Here} will do
the job for you.
The name of the command \markright requires a little explanation. An option
that we will not use in this tutorial is \documentclass[twoside]{article},
which produces pages formatted as in a book, i.e., with a left page and a right
page. Using this option it is possible to produce different headings for the
left and right pages. When using the default of one-sided pages, all pages are
thought of as right pages, and we use \markright to mark our headings on
these right-sided pages.