Latex - IAPP
Contents |
General
Help
If you want to open the documentation of some package you do not need google, just run
texdoc NAME
in a terminal (Linux) or DOS-prompt (Windows)
Splitting of your Thesis
You better not try to write your whole thesis in one single tex-file. It helps a lot to split it into several files (e.g. one header file + one file per chapter). Than you can choose between two commands: \include{File} adds a pagebreak while input{File} does not.
Hyphenation (Silbentrennung)
\hyphenation{ % tells Latex where it is allowed to split a word (or not)
ein % = do not split this word!
Größen-ver-tei-lung
Ins-ti-tut
mag-ne-tisch
}
When writing in German this might be useful:
\usepackage[T1]{fontenc} % Worttrennung von Worten mit Umlauten möglich
Units of length
- em The width of the letter M in the current font
- ex The height of the letter x in the current font
- cm Centimetres
- mm Millimeters
- in Inches
- pt Points (1in = 72.27pt)
- pc Picas (1pc = 12pt)
Math
Comma vs. Point
Latex handles commas different from (decimal) points. After a comma a little space in inserted. Compare the following in Latex:
$1234.5678$ $1234,5678$
In the web you find several workarounds for this problem, but they might easily generate new problems when interacting with other packages, so it might be safer to use only dots instead. If you do so, you should put a note at the beginning of your thesis, telling that you do not stick to the German standard due to technical issues.
Words in Subscripts
When writing words in subscripts use \text{} to prevent the letters from being printed in italics like variables:
- Use this: $E_\text{Photon}$ (looks similar to this: EPhoton)
- And not this: $E_{Photon}$ (looks similar to this: EPhoton)
Numbers and Units
When writing about numbers and units the following problems can arise
- missing or to big space between number an unit (this is correct: 12.32\,cm)
- unit must not be written in italic letters, when in math mode (use \text{})
- number and unit may be separated by end of line (\, helps again)
Instead of this it is a lot easier to avoid this kind of problems by using the SIunits packet and defining own unit-commands:
\usepackage[squaren,textstyle]{SIunits}
% adds support for SI units like \ampere, \ohm
% defines \unit, usage: \unit{10}{\centi\meter}
- textstyle for using the same font, than the surrounding text
- if textstyle is used, only buildin units should be used: cm->\centi\meter
- squaren for problems with amssyb package
Here some self-defined commands as example:
\newcommand{\grad}[1]{\unit{#1}{\degree}}
\newcommand{\uW} [1]{\unit{#1}{\micro\watt}}
\newcommand{\eV} [1]{\unit{#1}{\electronvolt}}
\newcommand{\meV} [1]{\unit{#1}{\milli\electronvolt}}
\newcommand{\nm} [1]{\unit{#1}{\nano\meter}}
\newcommand{\um} [1]{\unit{#1}{\micro\meter}}
\newcommand{\mm} [1]{\unit{#1}{\milli\meter}}
\newcommand{\sek} [1]{\unit{#1}{\second}}
Usage: A temperature of \grad{123} was measured...
equation, eqnarray or align?
Just use align! (see this example or l2tabu.pdf)
\begin{align}
z_0 &= d = 0 \\
z_{n+1} &= z_n^2+c
\end{align}
Layout
Documentclass
Here are some interesting options for the KoMa classes (scrartcl, srcreprt, srcbook, scrlttr2)
\documentclass[
a4paper
%,draft % draft/final
,12pt % 10pt, 11pt, 12pt
,twoside % one/two: different layout for left/right pages
,onecolumn % one/two
,fleqn % equations aligned left
,ngerman %
,titlepage % titlepage / notitlepage = title on a page of its own
,liststotoc %or ...numbered % list of figures + -tables to table of contents
,bibtotoc % Lit Verz -> TOC
,abstracton % writs the word abstract above the abstract
%,noonelinecaption % table + figure captions of only one line are not treated different to multiline-ones
,bigheadings % big-,normal-, smallheadings: sets size of section-headings, std=big
,openany % openright : new chapters only on right pages, openany: do not care (only for scrreprt and scrbook, not scrartcl)
]{scrreprt}
Paragraph separator: vertical space instead of horizontal offset
By default Latex separates paragraphs (indicated by an empty line in the source code) not by a vertical offset as it might be expected (and what is the standard in German language) but by inserting a horizontal offset before the first word of the new paragraph (as it is common in novels). In order to change this behavior to the "German" way do the following:
% Seperate paragraphs by an empty line instead of intending the line
\setlength{\parskip}{2ex plus0.5ex minus0.3ex}
\setlength{\parindent}{0pt}
Language
\usepackage[ngerman]{babel}
Umlaute
%\usepackage[latin1]{inputenc} % Umlaute (Windows)
\usepackage[utf8]{inputenc} % Umlaute (Linux)
Page Borders
\usepackage{geometry}
\geometry{left=3cm,textwidth=15cm,top=3cm,textheight=23.5cm} % A4: 21cm x 29.7cm
Page Layout via KoMa
\usepackage[automark]{scrpage2} % KOMA layout paket, automark is important!
- in the following the optional parameter [] are valid for opening pages like the first page of each chapter
- i=inner side, o=outer side, c=center
\pagestyle{scrheadings}
\ohead[\pagemark{}]{\pagemark{}}
\chead[]{}
\ihead[]{\textbf{\headmark}}
\cfoot[--- \pagemark{} ---]{--- \pagemark{} ---}
\ofoot[]{}
\ifoot[]{}
\setheadtopline{}
\setheadsepline{0.4pt}
\setfootsepline{}
\setfootbotline{}
Prevent Overfull Lines
% penalty for words split on two lines \hyphenpenalty=500 % from l2tabu.pdf (Latex Sündenregister), page 6 \tolerance 1414 \hbadness 1414 \emergencystretch 1.5em \hfuzz 0.3pt \widowpenalty=10000 \vfuzz \hfuzz \raggedbottom
Tricks
Enlarge Textarea of the Table of Contents (Inhaltsverzeichnis)
If your table of contents is 2-3 lines too long to fit on one page, you might be interesting in the following workaround that decreases the space on the top of the TOC page. Stolen from [1]
\newcommand*\backupvskip{} % safes the original \chapterheadstartvskip
\let\backupvskip\chapterheadstartvskip
\renewcommand*\chapterheadstartvskip{\vspace{-2\baselineskip}} % redefines it, -1cm etc also possible
\tableofcontents % prints the TOC
\let\chapterheadstartvskip\backupvskip % restores the spacing
Graphics
- Export your measurement plots in .pdf format (if possible) since this is will lead to vector graphics
- If .pdf is not possible use eps and convert to pdf afterwards:
epstopdf is a handy tool...
Windows .bat to convert all eps in folder to pdf:
for %%B in (*.eps) do epstopdf %%B
BibTex
Package cite
JabRef + Latex
Style Sheets
Create your own personal Bibtex style
Just run
latex makebst
and answer quite a lot of questions (help can be found here [2] and [3]). This produces a batch (.dbj) file, that can be converted into a bibtex style if you say so at the last question, or by manually running latex FILENAME you chose)
If you want to re-run it with only little changes, you might prefer to edit the batchfile insteat...
Copy the Bibtex style of a famous journal
Just click: [4]
Nice Packages
Float Barrier
\usepackage{placeins}
% defines the command \FloatBarrier: the name is program, no from above are allowed to pass this barrier
% [section] : floats are not allowed to travel into another section
Rotated Table (Tabelle im Querformat)
\usepackage{longtable}
\usepackage{rotating}
...
\begin{sidewaystable}
\centering
\begin{longtable}{|lll|}
...
table body
...
\caption{caption}
\label{tab:label}
\end{longtable}
\end{sidewaystable}
Rotate single cells of a table
\usepackage{rotating}
...
\begin{tabular}{|c|c|}\hline
Name &\begin{sideways}Grade\end{sideways} \\
\hline
Name 1 & 3 \\
Name 2 & 1 \\
\hline
\end{tabular}