Overview
LaTeX documentation
There is a lot of different documentation on LaTeX on the web. Only a small part of them is presented below. We are always grateful for advice and additions!
Introductory documentation
- Brief description of LaTeX2e. It is suitable for absolute and advanced beginners.
Commands
A list of (all) commands in LaTeX. They are good for reference.
Packages/Styles
LaTeX Literature
There are three books that are recommended again and again:
- Goossens Michel et al: Der Latex-Begleiter.
Verlag: Addison-Wesley, 1995, ISBN 3-89319-646-3, DM 79.90
Note: Tips, tricks, many LaTeX(2e) macro packages, for intermediate and advanced beginners.
The German version of this book should be preferred, as it has been revised several times and already contains references to newer packages. - Lamport, Leslie: Das LaTeX Handbuch.
Verlag: Addison-Wesley, 1995, ISBN 3-89319-826-1, DM 69.90
Note: the LaTeX(2e) reference, for beginners - Kopka, Helmut: LaTeX, Volume 1: Introduction.
Publisher: Addison-Wesley, 2nd, revised edition, 1996, ISBN 3-8273-1025-3, DM 69.90
Note: From the 2nd edition also LaTeX2e, good command overview in the appendix, for beginners
LaTeX FAQ
How do I set up an inputs directory?
If you have certain headers or definitions that are used frequently or even regularly, you can create a directory \\unixhome\inputs and move the file with the definitions here.
What does an optimal TeX file look like?
Optimal is always relative. The following should be used for German texts:
\documentclass[12pt]{article}
\usepackage[latin1]{inputenc}
% so that umlauts can be entered directly and recognised.
\usepackage[T1]{fontenc}
% Umlauts are regarded as one unit -> correct separation;
% in addition: the T1 fonts are also available in larger sizes
\usepackage[german]{babel}
%with this you get e.g. 'Fig.' instead of 'Fig.' for image captions
\begin{document}
...
\end{document}
Please no longer use '\documentstyle', this is obsolete.
How do I create slides?
The best way to create slides is with the seminar package. In addition to the slides, a handout can also be created.
Other recommended packages are
Prosper
latex-beamer
Example for slides in landscape format:
\documentclass[landscape]{seminar}
\centerslidesfalse
\begin{document}
\begin{slide}
% 1st slide
text
\end{slide}
Attention:
- xdvi must be called with the -paper a4r option.
-
dvips must be called with the option -t landscape. Then you will receive a correctly displayed ps file.
-
This ps file can then be printed without any further options
Example for slides in portrait format:
\documentclass[portrait]{seminar}
\begin{document}
\begin{slide*} % 1st slide text
\end{slide*}
Attention: do not forget the * at
\begin{slide*}
If you want to enlarge the slides globally, the following commands must be included:
\setlength{\slidewidth}{25cm}
\setlength{\slideheight}{17cm}
How do you create symbols for the quantities IR, IN, etc.?
You have to include the package amsfonts.
\usepackage{amsfonts}
\begin{document}
$\mathbb{R}$
$\mathbb{C}$
$\mathbb{Z}$
$\mathbb{N}$
\end{document}
How do I obtain certain maths symbols?
You must include the amssymb package. A list of all symbols is provided at the end of the documentation.
How do I put a text in Landscape?
If you want to output a text completely in landscape, you only have to do the following:
\documentclass[landscape]{article}
\AtBeginDvi{\special{landscape}}
...
Attention:
xdvi does not yet display the slides correctly.
dvips can be called by specifying the \special{landscape} in the TeX file without further options. If this line is omitted from the TeX file, the option dvips -t landscape must be used.
This ps file can then be printed without any further options!
How do I set parts of a text to landscape? (back)
With the lscape package (this is part of the graphicx package)!
Example:
\usepackage{lscape}
...
\begin{landscape}
...
\end{landscape}
Attention:
A new page is always started.
Header and footer are not rotated.
xdvi does not display the pages correctly -> first convert to ps (with a simple dvips) and then view with gv.
The printout can be done with the normal options without any problems.
Documentation for the graphicx package can be found at grfguide.ps or epslatex.ps.
How do I change the header/footer?
There is the fancyhdr package, which can be used to make all conceivable changes to the header or footer, e.g.
3-division of header or footer (left-centre-right)
Lines between header and text (analogue always for footer)
multi-line headers
Headers that are wider than the text
different headers per chapter, on even/odd pages, etc.
so-called 'thumb indices' as in telephone directories (black chapter bars analogue to the telephone directory)
Images in the header
How can I change the appearance of the reference list?
There are various packages that can be used to change the reference list and the references to it:
natbib.sty: turns (1997a, 1997) into (1997,1997a)
germbib.sty: if you want to mix English and German literature
cite.sty: makes [1,2,3,4,7] [1-4,7]
Caution: Mixing different styles can sometimes lead to undesirable side effects.
If these packages are not sufficient, you can create your own bst file: you have to call latex makebst, then you will be asked some interactive questions about how the directory and the references should look.
How do I insert an .eps figure into LaTeX?
It is best to insert an eps image using the graphicx package. There are 2 very good documentations for embedding:
grfguide.ps
epslatex.ps
The difference between graphics and graphicx is also explained there.
What can you do with this package?
Rotate images
Scale images
Specify fixed width and height
Specify a specific bounding box
draft option, which specifies whether the images should also be printed
and much more
How do I move the image caption justified with the number?
LaTeX does not normally set the captions flush with the figure number, e.g.
To obtain a long caption with more than one line, you must include the following:
\usepackage[hang]{caption2}
How do I get TeX labelling in eps images?
If you create the images yourself with xfig, you have the following option of incorporating TeX constructs into an image:
In xfig, set the special flag (located under the text flags) to 'Special' for every text that contains any LaTeX command.
The file must be exported twice: as 'Combined PS/LaTeX (PS part)' and as 'Combined PS/LaTeX (LaTeX part)'. You will receive the files bild.pstex and bild.pstex_t
The whole thing is then integrated into TeX as follows
\usepackage{epsfig}
...
\input{image.pstex_t}
The disadvantage of the above method is of course that you always have to manage 2 files. It is much easier with the psfrag package.
Prerequisite: You have any placeholders in the image, e.g. tag
The image is only exported as an eps file.
Each tag in the (e)ps file is now replaced by the desired text with the help of:
\usepackage{psfrag}
...
\psfrag{tag}{complicated text like $x+y$}
This replaces the text 'tag' with 'Complicated text like $x+y$'.
With this package, you can either perform the replacement for a single image or in all images. Of course, the whole thing also works with finished eps files.
Attention:
The result is only visible after a transformation to Postscript with the help of dvips. The dvi file only mentions that one or more replacements have taken place.
The eps files must not contain any hatched text!
If you want to reduce/enlarge the drawing but not the font, you can include the image as follows
\includegraphics[scale=0.8]{image.eps}
If you also want to reduce/enlarge the font, use the following command:
\scalebox{0.8}{\includegraphics{image.eps}}
How do I avoid 'floating' images or tables?
You often want to have images exactly where they are in the tex-file. But: figure and table environments are floating environments, i.e. they are placed in a 'suitable' position by TeX. The 'h' option does not necessarily prevent them from moving, it does mean 'here', but only if it's possible. There is now an additional option in the float package: 'H'. This places an image at the specified position regardless of the page layout. Everyone should be aware that this may not necessarily look favourable.
\usepackage{float}
...
\begin{figure}[H]
\includegraphics{file.eps}
\caption{...}
\end{figure}
Another option is to not float the image. To get the same numbering as with floating images, you can define the following:
\makeatletter
\newcommand\figcaption{\def\@captype{figure}\caption}
\newcommand\tabcaption{\def\@captype{table}\caption}
\makeatother
And then you can embed the image or table as follows
\begin{minipage}{\textwidth}
\centering
\includegraphics{file.eps}
\figcaption{This is a non-floating image}
\label{fig:non:float}
\end{minipage}
The minipage is required so that the image and the labelling are not separated.
How do I create multi-column text?
Use of the multicol package for several columns or parallel package for 2 columns (e.g. for dictionaries).
How do I create multilingual text?
Using German/English as an example:
\usepackage[german,english]{babel}
...
\selectlanguage{german}
Here comes the German text.
\selectlanguage{english}
And here is the english version
This correctly separates and adapts the caption for images to the languages. The babel package is much more important when switching to Greek, for example, for which there are completely different characters. All supported languages are listed in the babel documentation.
How do I write letters?
The LaTeX class letter is not particularly suitable for writing letters with a German layout. Better are scrlettr (from the koma-script) or the dinbrief.
Examples for scrlettr:
\documentclass{scrlettr}
\usepackage[german]{babel}
\address{Sabine Wetzel\\Soundsostr. 1000\\94036 Passau}
\date{25.10.2006}
% current date, if field is empty
\signature{Wetzel S.}
\begin{document}
\begin{letter}{Heinrich Hugo\\Nochnestr. 1\\50000 Musterstadt}
\opening{Dear Sir or Madam,}
I hope that you will send me 200 bars of chocolate as soon as possible.
\closing{With kind regards}
\end{letter}
\end{document}
How do I get certain special characters?
Sometimes people need certain special characters, such as a lightning bolt (for a contradiction), a telephone, a per mille sign, a space character, etc. These can be obtained with the help of the wasysym package. These can be obtained using the wasysym package:
\usepackage{wasysym}
To create the euro sign, you have the following option:
\usepackage{marvosym}
\euro{}
The eurosym package also recognises different fonts (such as italics or bold)!
How can I get special characters in headings or image captions?
Some special characters in TeX are fragile, i.e. if they occur in certain environments such as headings, they are no longer displayed. Ex:
$S_{\left( 0 \right)}$
should create a capital S with index (0). How do you get something like this in headings? Humans write in front of the fragile characters a
\protect
e.g.
$S_{\protect\left( 0 \protect\right)}$
How do I create large tables?
With large tables, people often have problems with page breaks and labelling. The supertabular and longtable packages support large tables.
How do I get coloured text?
The best way to get coloured text is to use the colour style, a part of the graphicx package (grfguide.ps or epslatex.ps).
Examples:
\usepackage{color}
\setcolor{red}
% or
\color{red}
Why are words not separated correctly?
This is probably due to the fact that the cm-fonts (standard) have been loaded, which understand umlauts as a combination of the letter with 2 dots and not as a single letter. If you use the ec fonts instead with the help of
\usepackage[T1]{fontenc}
the separation problems should be eliminated.
Which packages are best for the thesis/doctoral dissertation/poster?
The koma package is very suitable for theses. It provides all the commands (and a few more nice ones) of the normal article/report/book classes, but adapted to German conditions. You therefore use scrartcl/scrreprt/scrbook.
Examples:
\documentclass[12pt,a4paper]{scrbook}
\begin{document}
...
\end{document}
This package can be used to set the following things, among others
Width and height of the page
Extra margin for the hole punching/binding
Page size: from DIN A0 everything is possible
There is also a template for German letters (scrlettr).
How do I create an index?
To include an index, you can write the following in the TeX file hello.tex:
...
\usepackage{makeidx}
\makeindex
...
\begin{document}
\index{geometric symmetry} % arranges under 'G'
\index{Symmetry!geometric} % arranges under 'S'
...
\printindex % to the position where the index should appear in the text
\end{document}
After the latex run, you can call makeindex hello and then latex again.
How do I create a glossary (list of abbreviations)?
To include a glossary, you can write the following in the TeX file (hallo.tex):
...
\usepackage{nomencl}
\makeglossary ...
\begin{document}
...
\printglossary % to the position where the list of abbreviations should appear
\nomenclature[option]{$variable$}{definition}
\end{document}
After the latex run, you can call makeindex hello and then latex again.
How do I integrate source code into TeX?
There are various ways of integrating source code into TeX. Often a
\begin{verbatim}
...
\end{verbatim}
is often not enough, as you want to emphasise the programme structure or add a few comments. The following options are available:
Human uses the verbatim package:
\usepackage{verbatim}
\begin{document}
...
\verbatiminput{file.c}
...
\end{document}
moreverb package: Changing the tabs is possible. Line numbers can also be added.
listings package: Contains the option of displaying keywords and comments in different fonts.
fancyvrb package: Many useful extensions.
How can I write more eye-friendly with TeX?
Especially when developing papers, people often have to put up with the not very legible font in xdvi. The use of Helvetica is much easier on the eyes. You can use the following command for this:
\renewcommand{\familydefault}{phv}
Why does amstex no longer work?
The amstex package is obsolete. You should use the amsmath, amsfonts or amslatex packages. However, a few commands look slightly different there, such as the subequation command:
\begin{subequations}
label{total} %total = 2.52
\begin{gather}
equation 1\label{sub1} \\ % sub1 = 2.52a
equation 2\label{sub2} \\ % sub2 = 2.52b
\end{gather}
\end{subequations}
The quantity symbols are also generated in a different way.
More detailed information can be found in the documentation of the packages or in chapter 8 of the LaTeX Companion
How can I create variable margins?
The whole thing works with the geometry package:
\usepackage{geometry}
\geometry{a4paper,left=40mm,right=30mm, top=1cm, bottom=2cm} % and many other options.
How do you get different line spacing?
The whole thing works with the setspace package:
\usepackage{setspace}
\begin{document}
\onehalfspacing %or
\doublespacing %or
\singlespacing %or
\begin{spacing}{2.3}
...
\end{spacing}
\end{document}
How do you write vectors?
A standard way to write vectors in LaTeX is:
\overrightarrow{ABC}
However, the arrow is pressed quite close to the letters. The following works better in this case (with a variable distance setting)
\documentclass{article}
\makeatletter
\def\rpd#1#2{\vbox{\m@th\ialign{##\crcr
\rightarrowfill\crcrcr\noalign{\kern#1\p@\nointerlineskip}
$\hfil\displaystyle{#2}\hfil$\crcr}}}
\makeatother
\begin{document}
% rpd stands for right-arrow-above
% 1. arg. is the horizontal distance of the arrow to the text
\rpd{1}{AB}
\end{document}
What is the best way to align mathematical equations?
There are many environments in the amslatex package for aligning mathematical equations, such as equation, gather, multline, split, aligh, flalign, alignat. In addition to the general documentation for amslatex, there is also separate documentation. The old amstex should no longer be used.
How do I write in cursive?
If you want to use a beautiful script font for certificates, vouchers etc., you can use the calligra package.
\documentclass[20pt]{extarticle}
\usepackage{calligra}
\begin{document}
\calligra
\begin{centre}
{\huge document}
\end{centre}
\end{document}
Please note that the output is only displayed nicely in the postscript file or in the printout and that some letters or special characters do not yet work. Just give it a try~
If there is not enough space, a new page should be started.
This can be done with the following macro from refman.sty:
\newcommand{\condbreak}[1]{%
\vskip 0pt plus #1%
\pagebreak[3]%
\vskip 0pt plus -#1\relax}
How do I integrate a Framemaker image into TeX?
The following script can be found on the dvips page:
awk ' /FMPColor/ { del = 0 } \
{ if (del) { print "%", $0 } else { print $0 }} \
/xscale exch def/ { del = 1 } '