RBM LaTeX tips

The following tips are only short solution possibilities. To see the full functionality of the packages, you should read the documentation for the packages!

 

The documentation for (all) packages can be found (locally) at

 

/usr/share/texmf/doc/index.html

On this page there are also links to the official FAQ's of TeX. Please visit them in case of problems beyond those listed below! For further questions we are of course available as always.

 

 

How to set up an inputs directory?

Hat man bestimmte Header oder Definitionen, die öfter oder sogar regelmässig benutzt werden, so kann man sich ein Verzeichnis \\unixhome\inputs anlegen, und die Datei mit den Definitionen hierher verschieben.

 

What does an optimal TeX file look like?

Optimal is always relative. For German texts the following should be included:


\documentclass[12pt]{article}

\usepackage[latin1]{inputenc}

% so that you can enter umlauts directly and they will be recognized.

\usepackage[T1]{fontenc}


% umlauts are considered as one unit -> correct separation;

% besides: the T1 fonts are also available in larger sizes

\usepackage[german]{babel}


%hierwith you get e.g. 'Fig.' instead of 'Fig.' for image captions

\begin{document}

...

\end{document}

Please don't use '\documentstyle' anymore, it's deprecated!


How do I create slides?

 

The best way to create slides is to use the seminar package. In addition to the slides you can also create a handout.

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 option -paper a4r!

    dvips must be called with the option -t landscape! Then you get a correctly displayed ps-file.

    This ps-file can then be printed without any problems and without 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, you have to include the following commands:

\setlength{\slidewidth}{25cm}

\setlength{\slideheight}{17cm}
How do you create symbols for the sets 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 you get certain math symbols?

You have to include the package amssymb.  A list of all symbols is given at the end of the documentation.
How to set a text to landscape?

If you want to set a text to landscape you just have to do the following:


\documentclass[landscape]{article}

\AtBeginDvi{\special{landscape}}

...


Attention:

xdvi does not display the slides correctly yet!

dvips can be called by specifying the \special{landscape} in the TeX file without any further options. If you omit this line from the TeX file, you have to use the option dvips -t landscape.

This ps-file can then be printed without further options!

How to set parts of a text to landscape? (back)


With the lscape package (which is a part of the graphicx package)!

Example:

\usepackage{lscape}

...

\begin{landscape}

...

\end{landscape}


Attention:

Always a new page will be 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!

Printing can be done without problems with the normal options.

Documentation for the graphicx package can be found at grfguide.ps or epslatex.ps.


How to change the header/footer?

There is a package called fancyhdr which can be used to make all kinds of changes in the header/footer, e.g.


3-division of header/footer (left-center-right)

lines between header and text (analog always for footer)

multiline headers

headers that are wider than the text

different headers per chapter, on even/odd pages, etc.

so called 'Thumb-Indices' like in telephone books (black chapter bars analogous to telephone book)

images in the header

How can I change the appearance of the bibliography?

There are several packages that can be used to change the bibliography and the references to it:


natbib.sty: makes from (1997a, 1997) (1997,1997a)

germbib.sty: if you want to have english and german literature mixed

cite.sty: makes out [1,2,3,4,7] [1-4,7]

Attention: Mixing different styles can sometimes cause unwanted 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 interactively some questions, how the directory and the references should look like.


How to insert an eps image in LaTeX?

The best way to insert an eps image is to use the graphicx package. There are 2 very good documentations for inserting:


grfguide.ps

epslatex.ps

There is also an explanation of the difference between graphics andgraphicx.

What can you do with this package e.g.?


Rotate images

scale images

specify fixed width and height

specify specific bounding box

draft option to specify if the images should be printed as well

and much more

How to move the image caption flush after the number?

LaTeX normally does not set the image captions flush to the figure number, so e.g.


To get a long caption with more than one line. you have to include the following:


\usepackage[hang]{caption2}


How to get a TeX caption in eps images?

If you create the images yourself with xfig, you have the following possibility to include TeX constructs in an image:


In xfig, for any text that contains any LaTeX command, set the Special Flag (which is under the Text Flags) to 'Special'.

The file must be exported twice: as 'Combined PS/LaTeX (PS part)' and as 'Combined PS/LaTeX (LaTeX part)'. You get the files image.pstex and image.pstex_t.

The whole thing is then included in 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 package psfrag.


Precondition: you have some placeholders in the image, e.g. tag.

The image is exported only as an eps file.

Every tag in the (e)ps-file is replaced by the desired text with the help of:

\usepackage{psfrag}

...

\psfrag{tag}{complicated text like $x+y$}

This will replace the text 'tag' with 'Complicated text like $x+y$'.

With this package you can do the replacement either for a single image or in all images. Of course, the whole thing also works with already finished eps files.


Attention:

The result will be visible only after a transformation to postscript with the help of dvips. In the dvi-file it is only mentioned that one/some substitution/s 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 have to 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 to avoid floating of images or tables?

Often you 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 by TeX at a 'suitable' position. The option 'h' does not necessarily prevent wandering either, it means 'here', but only if this is possible. In the package float there is now an additional option: 'H'. This places an image at the specified location without regard to the page layout. Everyone should be aware that this may not look favorable.


\usepackage{float}

 ...

\begin{figure}[H]


\includegraphics{file.eps}

 \caption{...}


\end{figure}


Another option is to not float the image. Then to get the same numbering as with floating images you have to define the following:


\makeatletter


\newcommand\figcaption{\def\@captype{figure}\caption}

 \newcommand\figcaption{\def\@captype{table}\caption}


\makeatother

And then you can include 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}

You need the minipage so that the image and the label are not separated.


How to create multicolumn text?

Use the multicol package for multiple columns or parallel package for 2 columns (e.g. for dictionaries).


How to create multilingual text?

Using the example German/English:


\usepackage[german,english]{babel}

...

\selectlanguage{german}

Here comes the German text.

\selectlanguage{english}

And here is the english version

This will separate correctly, the caption for images will be adapted to the languages. Much more important is the babel package when changing e.g. to Greek, for which there are completely different characters.  In the documentation of babel all supported languages are listed.


How to write letters?

To write letters with German layout, the LaTeX class letter is not very suitable. Better are scrlettr (from koma-script) or dinbrief.

Examples for scrlettr:


\documentclass{scrlettr}

\usepackage[german]{babel}

\address{Sabine Wetzel\Soundsostr. 1000\94036 Passau}

\date{25.10.2006}


% current date, if field empty


\signature{Wetzel S.}

\begin{document}

\begin{letter}{Heinrich Hugo\Nochnestr. 1\50000 Musterstadt}

\opening{Dear Sirs,}

I hope that you will send me 200 bars of chocolate as soon as possible.

\With kind regards

\end{letter}

\end{document}

Where can I get certain special characters?

Sometimes you need certain special characters, like a lightning bolt (for a contradiction), a telephone, a per mille sign, a space sign, etc.. You can get them with the help of the wasysym package:


\usepackage{wasysym}

To create the euro sign you have the following option:


\usepackage{marvosym}

\euro{}

With the eurosym package also different fonts (like italic or bold) are respected!


How to get special characters in headings or image captions?

Some special characters in TeX are fragile, i.e. if they appear in certain environments like headings, they will not be displayed anymore. Ex:


$S_{\left( 0 \right)}$

should create a capital S with index (0). How do you get such a thing in headings? One writes before the fragile characters in each case a


\protect

e.g.

$S_{\protect\left( 0 \protect\right)}$

How to make large tables?

With large tables you often have problems with page breaks and labels. The supertabular or longtable packages support large tables.


How to get colored text?

Colored text is best obtained with the color 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 because the cm-fonts (default) 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 to use for the thesis/doctoral paper/poster? (back)


For diploma theses the koma package is very suitable. It provides all commands (and a few nice ones) of the normal article/report/book classes, but adapted to German conditions. One thus uses scrartcl/scrreprt/scrbook.


Examples:

\documentclass[12pt,a4paper]{scrbook}

\begin{document}

...

\end{document}

With the help of this package the following things can be set, among others:


width and height of the page

Extra margin for punching/binding

Sheet size: from DIN A0 everything is possible

There is also a template for German letters (scrlettr).

How to create an index?

To include an index, you have to write the following into the TeX file hallo.tex:

 ...

\usepackage{makeidx}

\makeindex

...

\begin{document}

\index{geometric symmetry} % files under 'G'.

\index{Symmetry!geometric} % files under 'S'

...

\printindex{index} % to the place where the index should appear in the text

\end{document}

After the latex run you have to call makeindex hello and then latex again.


How to create a glossary (list of abbreviations)? (back)


To include a glossary, you have to write the following in the TeX file (hallo.tex):


...

\usepackage{nomencl}

\makeglossary ...

\begin{document}

...

\printglossary % to the place where the list of abbreviations should appear.

\nomenclature[option]{$variable$}{definition}

\end{document}

After the latex run you have to call makeindex hello and then latex again.


How to include source code in TeX?

There are several ways to include source code in TeX. Often a


\begin{verbatim}

...

\end{verbatim}

is not sufficient, because you want to emphasize the program structure or add some comments. You have the following possibilities:

Use the verbatim package:

\usepackage{verbatim}

\begin{document}

...

\verbatiminput{file.c}

...

\end{document}

moreverb package: changing tabs is possible. Line numbers can also be added.

listings package: Includes the possibility to display keywords and comments in different fonts.

fancyvrb package: Many useful extensions.

How to write more eye-friendly with TeX?

Especially when developing papers, you often have to put up with the not very readable font in xdvi. Much easier on the eyes is the use of Helvetica. For this you have to include the following command:


\renewcommand{\familydefault}{phv}

Attention:

In my opinion, this command should only be included during the development phase. For printing you can comment it out!

Why does amstex not work anymore?

The package amstex is obsolete. You should use the packages amsmath or amsfonts or amslatex. However, some commands look a bit different there, like the subequation command:


\begin{subequations}

label{total} %total = 2.52

\begin{gather}

equation 1\label{sub1} \begin{subequations} %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 to make the margins variable?

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 to 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}

...

\endspacing}

\end{document}

How to write vectors? (back)


A standard way to write vectors in LaTeX is:


\overrightarrow{ABC}

However, this pushes the arrow quite close to the letters. The following works better in this case (with a variable setting of the distance):


\documentclass{article}

\makeatletter

\def\rpd#1#2{\vbox{\m@th\ialign{##\crcr

\rightarrowfill\cr\noalign{\kern#1\p@\nointerlineskip}

$\hfil\displaystyle{#2}\hfil$\crcr}}

\makeatother

\begin{document}

% rpd stands for right-arrow-over.

% 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?

For aligning mathematical equations there are many environments in the package amslatex, such as equation, gather, multline, split, aligh, flalign, alignat. Besides the general documentation of amslatex there are other separate documentations. The old amstex should not be used anymore.


How to write in nice cursive?

If you want a nice cursive font for certificates, vouchers etc., you can use the calligra package.


\documentclass[20pt]{extarticle}

\usepackage{calligra}

\begin{document}

\calligra

\begin{center}

{extarticle}

\end{center}

\end{document}

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 work yet. Just try it out!


If there is not enough space left, 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 to embed a Framemaker image in TeX? (back)


On the dvips page you can find the following script:


awk ' /FMPColor/ { del = 0 } \

{ if (del) { print "%", $0 } else { print $0 }} \

/xscale exch def/ { del = 1 } '