This page does not tell you how to use LaTeX per se, because there are better and more complete sources. Rather, this document focuses on the following: (i) list sources for general information about LaTeX, (ii) give local information to complement the general information, and (iii) provide relevant examples of concrete uses of LaTeX as needed, for instance, for project reports in my courses.
As for Point (iii), the examples are not the only way to accomplish certain tasks, but they have worked for me, and I am just sharing my experience with the community. In many cases, this webpage might provide additional commentary on why certain things were done a certain way, see for instance the discussion on producing clean PDF documents below.
The information in this page should be applicable, no matter under which operating system you use LaTeX. However, when I give concrete commands showing how to process or preview LaTeX documents, I will assume that you are using a Unix/Linux machine. See your local information how to process LaTeX under other operating systems.
You are welcome to tell others about this page and to create a link to it. Instead of providing a live link to this page, I suggest to link to my homepage like I have done above. I have tried my best to be brief as well as accurate, but you will know how hard this is, if you tried to put together a document like this yourself. If you find any mistakes or have comments, please contact me at gobbert@math.umbc.edu.
In more modern web-parlance, they are mark-up languages, in which the writer merely indicates the structure of the document (e.g., ``start a new section here''), but the actual appearance is controlled by class and style files (e.g., how a section header is actually formatted).
Side-note on the effect of all this: LaTeX has turned math professors into typesetters and publishers like Springer into celebrated copy shops: They receive a type-set and fully paginated manuscript from the author, all the publisher does is to have the master copy ``photo-copied,'' send it to the binder, and put a cover around it. And that's what they charge a lot of money for ... .
A lot of other things could be said here, for instance, about the choice of the name and its Capitalization (to avoid patent infringement on the material latex as in ``latex gloves''). I refer to the section on ``The Game of the Name'' in Lamport's book; see below for full reference.
Additionally, let me point out that there are also various other versions of TeX and LaTeX, like AMS-TeX and AMS-LaTeX, propagated by the American Mathematical Society. Those are genuinely different packages than TeX or LaTeX with quite different appearance and partially different commands; I do not use them.
On the other hand, as LaTeX is freely distributed, there are distributions of it, like teTeX included with Linux distributions. Such distributions include, if they are LaTeX2e compatible, a large number of so-called standard packages like amsmath, citesort, graphicx, and many others, all of which are not part of LaTeX, but genuine extensions that provide additional features and functionality.
The books listed below are all appropriate for LaTeX2e. The starting point should always be the book by Leslie Lamport, which is both concise and readable and which explains LaTeX's philosophy well. The price paid for both is lack of completeness, when it comes to advanced features. In this context, ``advanced features'' include redefining section headers, importing postscript (or other) files, and overcoming the struggle with float placement. I have found both the book by Michel Goossens, Frank Mittelbach, and Alexander Samarin as well as the one by George Grätzer useful - in different ways: Goossens et al. is organized `horizontally' and discusses material organized by package; I suggest to use it, if you want to dig into the innards of LaTeX2e like redefining section headers or advanced float placement. Compared to that, Grätzer is organized `vertically,' because it discusses tools for one topic from all available sources together. If you need to typeset very complicted formulas or have other problems with the mathematics, I recommend Grätzer because of its well-chosen examples and its organization.
Considering we are in the 21st century, I must mention the huge repository for information and macros put out by the TeX Users Group (abbreviated as TUG). You can find them at http://www.tug.org/. There is a wealth of information available including style files and similar. Or for that matter, I have been rather successful with google searches, if I had specific problems.
Recommended books:
thebibliography environment.
It also contains a wealth of examples of the typsetting of the most
common mathematical constructs like fractions and matrices.
For more advanced features, see the Template for Project Reports below.
Click on this link to sample.tex
to download it to your computer.
To process the file, use the following command sequence
at the Unix/Linux prompt:
latex sample.tex
latex sample.tex
dvips sample.dvi
Notice that running LaTeX twice is needed to get the automatic cross-referencing right.
The resulting postscript file sample.ps can be viewed on
the screen using gv sample.ps and then be printed using
lpr sample.ps.
Files needed to use the template:
The LaTeX source template.tex needs several other
files, namely the bibliography database file
template.bib and of course the postscript files
for the figures.
Recently, the PDF file format has proven to satisfy my requirements from a web standpoint: A PDF file will typically open up on a user's screen and hencs does not have to be ``downloaded'' in the traditional sense first. (Of course, it is downloaded as a temporary file, but the key is that it opens up automatically and the downloading is therefore transparent to the user.)
So, the problem has become how to turn LaTeX source code into a PDF file. There is one traditional way, which starts with the conventional latex and dvips doublestep and then translates (``distills'') the resulting postscript file into a PDF file using ps2pdf for instance. Most people will observe that the result does not look good on the screen, but will print fine (at least on a postscript printer).
Now, enter the NSF FastLane system. The philosophy in that case is really that the document should be readable on the screen! That made me investigate the issue farther. It turns out that the FAQ area of the FastLane pages have a lot of information on the issue. Searches on the internet turned up additional pages, some from Sponsored Programs offices addressing exactly FastLane issues. Basically, a number of options were suggested for the ps2pdf command to make fonts part of the PDF file, which seems to have been the core issue.
However, this process keeps having problem with plots in my files, which
were originally postscript files. Hence, I continued to look for a method
that would process my original LaTeX file directly. And that in fact exists:
The pdflatex utility processes a LaTeX document and directly
obtains a PDF file. What about the figures you ask? The right thing to do
is to supply them as PDF files, as well. So, the remaining ingredients are
an utility to convert each plot saved as a postscript file to a PDF file
and a LaTeX package that can import those PDF files into LaTeX's
figure environment. Those I found as well, and the details
follow presently.
There are in fact additional features available for PDF files: You can have live links in them, both to jump to other places in the same document or to connect (by starting a web browser) to any URL of your choice. Or I have seen PDF documents that contained multiple-choice quizzes; upon clicking on an answer choice, a window would open to tell you, whether you were correct. All these documents were created from LaTeX documents! I have not used these features personally.
figure
environment. I assume that these plots are stored in eps
files; this is the case, if you saved them from, for instance, Matlab
using the print command with the device (-d option)
as eps or eps2 (or epsc or epsc2
for color).
If you have no plots in your document, just leave out the the appropriate
steps below; however, read my warning about that below.
All utilities mentioned here are part of LaTeX2e's standard distribution.
Step 1:
Convert all postscript files (containing the individual plots) to PDF
using the epstopdf utility.
Example: Given a file sampleplot.eps
epstopdf sampleplot.eps
yields sampleplot.pdf.
Small warning: The full filename must contain no more than one period
(``.''), otherwise the naming scheme may get confused.
Step 2:
Install the needed commands in your LaTeX document, as follows:
You will need to include the package graphicx to
include the PDF files created in Step 1. To make things be formatted
properly, you should use it with the optional argument pdftex.
That is, install the line
\usepackage[pdftex]{graphicx}
after the \documentclass in your tex file.
To actually import a file, use the \includegraphics command
from the graphicx package, as in
\includegraphics[width=0.8\textwidth]{sampleplot.pdf}
This should be very similar to other import commands you may have used
in the past to import postscript files. Particularly, one should
always rescale the plot to either a specific width or height (but
not both), which will scale both directions equally. And the width
should generally be given relative to the \textwidth
of your document. See the template file for several
demonstrations of figure importing.
Step 3: Simply run pdflatex on your LaTeX document, as you would have run latex in the past:
pdflatex sample.tex
Run bibtex if you are using BibTeX. Run pdflatex
as many times as necessary to get cross-references right, just like
latex (no more than three times).
You should now have a PDF file sample.pdf.
You can preview it using, on Unix/Linux, the Acrobat Reader as in
acroread sample.pdf
\DeclareGraphicsExtensions{.pdf} immediately after the
\begin{document} command in your text. Then you do not
need the full filename sampleplot.pdf in the
\includegraphics command any more, but just the basename
sampleplot.
To switch over to using postscript files instead of PDF files for the plots,
just change the extension in \DeclareGraphicsExtensions{.pdf}
to .eps. To avoid warning messages, one should also delete
the optional argument pdftex from the
\usepackage[pdftex]{graphicx} command.
Note that if one wants to overwrite the behavior implied by
\DeclareGraphicsExtensions, one can give the
full filename in the \includegraphics command at any time.
\DeclareGraphicsExtensions also accepts multiple extensions
as in \DeclareGraphicsExtensions{.eps,.ps}, though
I have not used or tested this feature myself.
A full example of all this can be found in the template file above.
Look at the beginning of the file; you will find two lines with
\usepackage[]{graphicx}, once with and once without the
pdftex. Just after the \begin{document},
you will find two \DeclareGraphicsExtensions commands,
one with {.pdf} and one with {.eps}.
Comment in the two appropriate lines for your goal.
tex file described above
would look like this:
\documentclass{article}
% \usepackage[]{graphicx} % use this when importing ps- and eps-files
\usepackage[pdftex]{graphicx} % use this when importing PDF files
[...]
\begin{document}
% \DeclareGraphicsExtensions{.eps} % use this when importing eps-files
\DeclareGraphicsExtensions{.pdf} % use this when importing PDF files
[...]
% This imports the file ``sampleplot.pdf'':
\includegraphics[width=0.8\textwidth]{sampleplot}
[...]
\end{document}
Notice that the commands for postscript and PDF are both present, but
one set is commented out. See my template file above for more
complete demonstrations of the \includegraphics
command to import plots.
\usepackage[]{graphicx} line, if one does not want to
import figures, that is, for a pure text document.
But when I did that, FastLane could not determine the paper size
used and was unsure about margin sizes in my document! So,
clearly, some stuff was not being set properly by pdflatex.
I found that this gets fixed properly by using
\usepackage[pdftex]{graphicx}, whether importing
plots or not. So, I recommend to use that line in all cases.
A particular book to point to is Nicholas J. Higham, Handbook of Writing for the Mathematical Sciences, second edition, SIAM, 1998. If you are a Ph.D. student, I strongly recommend that you read this book, because it addresses many question about how publishing works in the sciences.
For a more complete literature list covering also other aspects of mathematics, see my homepage.