Chapter 8. LaTeX

Table of Contents
Running LaTeX from the shell
Running LaTeX from within emacs
How to learn more about LaTeX

LaTeX is a document preparation system that lets the author focus on the content and structure of the document rather than on the layout. The document is then typeset nicely according to a predefined layout. The document is written with a text editor like e.g. emacs and the final output is then very much different from what one sees on the screen.

A short LaTeX code that illustrates what was said above is the following minimal but complete listing of a LaTeX file:

\documentclass{article}

\author{Peter Olsson}
\title{A test document}

\begin{document}
\maketitle

\section{Short introduction}

\LaTeX\ is a document preparation system that lets the author focus
on the content and structure of the document rather than on the
layout. The document is then typeset nicely according to a predefined
layout.  \end{document} 


Running LaTeX from the shell

Create a new directory (mkdir) and cd to that directory. Open a new file short.tex in emacs and copy the above text into that buffer. Save the buffer with C-x C-s. As we will se below it is possible and very convenient to run both LaTeX and the viewer program from emacs, but to understand what is going on it is good to first do it from an xterm. Therefore, go back to the xterm and start emacs like this:

$ latex short

This is TeX, Version 3.14159 (Web2C 7.4.5)
(./short.tex LaTeX2e <2001/06/01> Babel <v3.7h> and
hyphenation patterns for american, nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/article.cls Document Class: article
2001/04/21 v1.4e Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo)) No file short.aux.  [1]
(./short.aux) ) Output written on short.dvi (1 page, 824 bytes).
Transcript written on short.log.

So far there is no visible result but LaTeX has created a number of files and of these it is the .dvi-file that contains the formatted document in a device-independent form. To take a look at the output do

$ xdvi short.dvi &

which will open a new window with the formatted output.


Running LaTeX from within emacs

To run LaTeX from emacs one can either choose LaTeX from the Command menu or press C-c C-c followed by return two times. To view what has been produced either press C-c C-c again. The text "Command: (default View)" then appears at the bottom line. After again pressing return twice a new window will be opened where the produced document appears.


How to learn more about LaTeX

Each LaTeX document is split into two parts, the preamble which only contains definitions and doesn't produce any output and the document itself which is the part between \begin{document} and \end{document}. LaTeX is a complicated system and is not easy to master. To produce standard documents with ordinary mathematics and included figures is however not at all difficult. The simplest way to proceed is to start from a skeleton file (see below) and learn new things by looking at others documents. To learn things in a more systematic way The Not So Short Introduction to LaTeX is a good place to start. To read the pdf file choose the program /usr/bin/acroread.

The predefined layout doesn't mean that there is no room for changing things. By including "\usepackage{umuphys}" in the preamble a local version of the \makefile command is included with a different layout of the titlepage. Beside the definitions of \author and \title this version also needs \course and allows for (but doesn't require) \email. Two versions of skeleton LaTeX files may be found in /home/stud-intro/latex: skeleton.tex and the swedish version skelett.tex. Copy both these files to your home directory. Open the files in emacs, run LaTeX and examine the output with the viewer.

An example file that illustrates equations, the inclusion of postscript figures, and tables may be found in /home/stud-intro/latex/example.tex. Note that you also need the figure in the postscript file /home/stud-intro/latex/example-fig.ps.