# Introduction to LaTeX

• TeX (pronounced "Tech") is a typesetting system developed after 1977 by Donald E. Knuth, out of frustration about the way his papers were rendered in the AMS (American Mathematical Society) publications. One important feature of TeX is its ability to handle mathematical formulas.
• LaTeX (pronounced "Lay-tech" or "Lah-tech") is a package which offers authors a predefined, professional layout. It was developed in 1985 by Leslie Lamport and uses TeX as its typesetting engine.
The advantage of LaTeX (which is similar to a markup-language) over TeX is that it facilitates very much the typesetting work. The downside is that one has less freedom in accessing some of the TeX features.
LaTeX is now mantained by the LaTeX3 Project. The current version of LaTeX is called LaTeX2e (where the "e" is an "epsilon"). The previous one was LaTeX 2.09.
• Another such package is AmSTeX, developed by the AMS. Most (all?) of its features and fonts can be incorporated in LaTeX, using the packages amsmath and amssymb. There is a short AMS guide for typesetting mathematics in LaTeX, including features provided by these packages.
• AMS-LaTeX incorporates some of the AmSTeX features into LaTeX, and the other way around.

• To dive into Latex without installing anything, can try www.overleaf.com.
Features:
• saves you the trouble of installing the software, has templates, etc.
• contains instructions and tutorials (see the "How do I use Overleaf" entry in their Help)
• allows multiple users to work on the same document
• many more
• THIS SECTION MIGHT NOT BE UP TO DATE

To install LaTeX on a PC, check, e.g, http://www.cv.nrao.edu/~abridle/toolmemo/toolmemo.shtml.
This contains a link to MiKTeX (http://www.miktex.org/), which is free. As of March 2016, it is the version installed on the Windows laptops in the department, works very well.
Other packages are also mentioned, e.g., emtex (which is free) and PCTeX (which is not).

• For other sites containg (La)TeX-related material, check the Internet Help section.
For a not very complete (but fast) help, check the Online help section.
Various "tricks" and examples are described in the Fancy Stuff section.

Producing a LaTeX (or TeX) document on a UNIX/Linux system requires a few stages. The commands below (`tex, latex, xdvi, dvips, dvipdf`, etc.) have to be issued in a shell. For many of them one need not include the extension in the file name.

Here is the basic sequence (see details below):

create the LaTeX file, say `FILE.tex`:
use any text editor
process the file:
`latex FILE`    (will use `FILE.tex` and produce `FILE.dvi`)
view the result on screen:
`xdvi FILE &`    (will use `FILE.dvi`)
printing (using a PostScript version)
`dvips FILE`    (will use `FILE.dvi` and produce `FILE.ps`)
followed by
```lpr FILE.ps```
A few extra features:
PDF-version
If you need a PDF version. e.g. to post on the Internet, there are a few choices. The extension is indicated to emphasize the file that is used.
• `dvipdf FILE.dvi`    (will produce `FILE.pdf`); this is similar to `dvips`, and might produce first `FILE.ps` and convert it to PDF with `ps2pdf`
• `pdflatex FILE.tex`    (will produce `FILE.pdf`); the figures should be available as PDF files. See more in the Pictures section.
• `vlatex FILE.tex`    (will produce `FILE.pdf`); handles pictures too, but `vlatex` is not part of the default installation
[by now `dvipdf` works for most cases, so no need for `vlatex`]
To add (click-able) hyperlinks for formula numbers, references etc., you could include `\usepackage{hyperref}` (preferably as the last package to be loaded). Often no other change is needed in the file. See the Fancy-stuff section.
Details:
1. Creating the ASCII (i.e., text) file containing the document. This file has customarily the extension .tex, and can be written with any text-editor.

2. "Compiling" it, with the command ```latex latex_file[.tex]``` (or, `tex tex_file[.tex]` if it is a TeX of AmSTeX file). This will produce a DVI (DeVice Independent) file, whose extension is ".dvi".
• For LaTeX documents, it might be necessary to run `latex` two or three times, in order to get the references and tables of content right. Normally LaTeX will specify this, but you can also see it from the DVI file: it will have references replaced by question marks.

3. On a graphic display the DVI file can be seen with the command `xdvi dvi_file[.dvi]`.
• Since we can use the same window to check the file as we are making changes, it is better to start this command in the background (i.e., followed by the symbol &)

4. Transforming the DVI file into a PS (PostScript) file, with the command `dvips dvi_file[.dvi]`. One can arrange that the PS file be sent directly to the printer, instead of being saved on the disk.
• If the PS file is saved on disk, it usually has the same name as the DVI file but the extension is ".ps". One can choose the name of the PS file (and force it to be saved, instead of being sent to the printer) with the option -o. To specify a different papertype (e.g., landscape, legal, letter, a4), use the parameter -t. Here are some examples:
• `dvips paper` transforms paper.dvi into a PS file and sends it to the default printer, or saves it as paper.ps (depending on how `dvips` is set-up).
• `dvips -P rm645 paper` transforms paper.dvi into a PS file and prints it on the printer rm645.
• `dvips -o new.ps paper` saves the PS output as new.ps (and normally does not sent it to the printer).
• The PS file can be displayed with the command ```ghostview ps_file``` or printed with the command `lpr ps_file` (both of these commands require the full file name as argument).
• Warning: DO NOT try to print the DVI file with `lpr` (even with the `-d` flag), it can lead to hundreds of garbage pages! If you do it, the damage can be limited (but not always avoided) with the command `lprm -`, which removes your jobs from the printer queue. The `lprm` command has to be issued from the same machine and directed to the same printer (with the `-P` parameter) as the `lpr` command.