Rein Smedinga
LaTeX is a text formatting program, i.e., after you have written a text into a file by means of an editor, the LaTeX-program converts this text into printable matter. With LaTeX you cannot do what-you-see-is-what-you-get work: you need two steps: one editing step in which you type in the text together with typesetting commands into a file; and one formatting step, in which the program converts the text, according to the given commands, in printable code.
The following steps have to be done:
emacs
:
emacs example.texThe UNIX command above starts the editor and creates the file
example.tex
. You should always give the file a name with extension
.tex
(otherwize LaTeX will not recognize the file as a text file).
latex exampleIt is not necessary to give the filename extension here. LaTeX now creates some additional files. One of these is the file
example.dvi
,that can be printed and previewed. Also
example.aux
is created (needed for cross referencing) and
example.log
in which LaTeX writes down a log of everything it has
done.
Because each language has its own hyphenation-rules, you can use other rules than English hyphenation by giving special commands in the file. We will return to this subject later on.
xdvi examplethe file
example.dvi
will be previewed on your screen.
your document will be printed. For printername fill in:lp -d
printernameexample.dvi
x
for
the Xerox printer on the ground floor, or lj4
for the HP laserjet
printer on the first floor.
As stated before,
the original text file example.tex
should not only contain text, but
also LaTeX-commands. First of all, you need to explain what kind of document
you want to make, and you should indicate the beginning and the end of the
included text. This is done by typing on the first lines of your text-file
the following:
\documentclass{article} \begin{document}The first line explains to LaTeX that you want to make an article. Changing
article
into report
creates a report. Also
book
and letter
are possible. The last one creates a letter
that can be mailed.
The second line tells LaTeX that after this line your real document starts. At the end of that document, you should add the following line:
\end{document}which tells LaTeX that your document ends here. Everything after this line will be ignored by LaTeX.
A very simple article could be:
Between \documentclass
and {article}
you can put all kind of
options to change the documentclass a little bit.
For example, by:
\documentclass[a4paper]{article}you create a document in a4 paper format.
Another possibility is to add extra tools. This is done by adding (after
the documentclass
-line) lines like:
\usepackage{epsf} \usepackage[dutch]{babel}The first line adds the epsf-tool with which eps-files can be included. The second line adds the babel-tool, with which multilanguage documents can be made. In this case the babel-tool has an additional option dutch, telling LaTeX that Dutch hyphenation should be used instead of English. Also, language-dependent words, like chapter, contents, etc. will automatically be renamed to the Dutch words hoofdstuk, inhoud, etc.
Another possibility to use here is the option to enlarge the used font a little bit. Instead of standard 10 pt. fonts you can use 11 pt. fonts by starting with:
\documentclass[11pt]{report}In the same way, you can use 12 pt. fonts. If you include more options, each option should be separated by a comma:
\documentclass[12pt,a4paper]{book}
In order to create a textfile, it will now be clear that the actual text has
to be put between \begin{document}
and \end{document}
.
However, in typing your text, you should be aware, that some characters have
special meaning. We mention
{ } \ # $ % &The backslash
\
is used to denote a command rather than normal text.
So text
is some text while \text
denotes a command. If you
want to use any of the above symbols, you should use
\{ \} \backslash \$ \% \&instead.
Commonly used commands are those to denote the beginning of a new chapter, new section, etc. We mention a few:
\chapter{name}
name
becomes the title of the new chapter. Chapter numbering and
adding the word chapter itself (or hoofdstuk, if the dutch option is used)
is done automatically.
\section{name}
name
is the title of the new section. Also here, numbering is done
automatically.
\subsection{name}Etc.
end of a line.\\ start of a next line...A newline command
\\
only works if a line can really be closed. So
\\ \\
is not allowed. The second \\
does not close a real line.
With \item
a new item will be started. Automatically, a marker will
be put before that item and the whole item will be indented. If you want to
number the items, you should use:
Numbering is done automatically. Itemize and enumerate lists can be nested and mixed.
\title{This is the title} \author{A. Writer and B. Reader} \date{tomorrow or so}and will be printed if you say:
\maketitleIn the article style the title and author-list will appear above the text, in report and book style it will be put on a separate page.
\tableofcontentsThis command creates an additional file, with extension
.toc
, that is
read in the second time, you process your document through LaTeX, to create
the table of contents. So, you need to give the UNIX command
latex exampletwice, to really get the (up to date) contents.
Some commonly used accents are:
be\"eindigento get beëindigen.
be\"\i nvloedto get: beïnvloed (the
\i
creates a dotless i).
\'e\'ento get: één.
The used font can be changed to for example boldface or italics by typing:
\textbf{this will be printed boldface} and this in normal font \emph{and this emphasized} and normal again and \textsl{slanted} and \textit{italics} and so on.The used font can be resized to smaller or
{\tiny very small text} {\footnotetext Quite small text} {\small Small text} {\normalsize is normally not used} {\large Larger text} {\LARGE Even larger text} {\Huge Very huge text}In fact, we have available:
\tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE \huge \Huge
LaTeX provides easy to use commands to create tables. For example:
The argument after \begin{tabular}
defines the structure of the
table. Each letter represents a column. A l
means a left alined
column, a c
means a centered column, and a r
means a right
alined column. Also possible is to put a |
there, to define a
vertical line between columns. The contents of each part of the table is
separated by &
and each line is ended by \\
. Much more complex
tables are possible. The reader is adviced to look in the LaTeX-manual,
[Lam94], for more examples.
Floating text is text that can be put somewhere in the text, but has no specific place within the text. For example figures and tables can be floats. They should be put near the place the figure or table is discussed. Such floats can be created in LaTeX by typing:
\begin{figure} Figure text... \caption{Figure title} \end{figure}The caption will create the title of the floating part. Also possible is:
\begin{table} Table text... \caption{Figure title} \end{table}The difference between
figure
and table
is the name in the
caption: Figure and Table, respectivily. Also here, numbering is done
automatically.
A mathematical formula is put between $
. For example:
Subscripts are defined using _
and superscripts using ^
. If
more characters are to be sub/superscripted, these should be put between
accolades, e.g. compare:
For displayed formulaes, we use:
Displayed formulaes are put on a separate line and centered.
\sum
is the summation symbol. In [Lam94] long lists of symbols
can be found.
The reader is adviced to read the LaTeX-manual [Lam94] to explore LaTeX. Sample text files exists, to get a first impression on LaTeX, for example try:
cp /usr/local/teTeX/texmf/tex/latex/base/sample2e.tex . latex sample2e xdvi sample2eand compare the contents of the file
sample2e.tex
with the previewed
result.
If some error occurs in your document, you get an error message on the screen. Something like:
! Undefined control sequence. l.22 ...eation of a text file with text and \LateX \ commands. Creation is ?The first line tells in which line of your text file the error occurs. The last part of that same line gives the part that causes the error. The question mark is a prompt. You can type
h
here to get additional information about the error.
Other possibilities are x
to quit the whole LaTeX-session, or giving
a return only, to let LaTeX try to fix the error by himself (possibly more
errors occur because of this error, so most likely, a couple of returns are
necessary to recover from this error; also, the error is not corrected in
your original text file!). The last option (giving a return) makes it
possible to check the remainder of the document. After a LaTeX-run you
should correct the error(s) yourself in your text file using an editor and,
next, try to run LaTeX again.