Useful Packages in the Preemble


Latex provides a wide variety of additional packages to extend it’s functionality or simply to make some things more convenient, automatic, and simpler to maintain.The following table gives an overview of the packages I use in a daily fashion for scientific publications (apart from the standard packages).


This is a very subtile but nice package that optimizes the typography of the paper on micro-level, e. g. by character protrusion and font-expansion. Just add the package to the preamble and see the difference - best recognized using an updating PDF viewer like Skim.


When in text mode (not equations), xfrac enables you to create nice fractions in both text mode and math mode. xfrac defines the command \sfrac, which can be used as in \sfrac{1}{2}.


Package for nice formatted (si-)units in a consistent way. To show 48 000 kHz, you can say: \SI{48000}{\kilo\hertz}. It not only formats the units nicely but also inserts thousands separators if desired and is heavily customizable. Anyhow, I am drifting away from using it these days, as it’s a lot to write something like \SI{128}{\kilo\bit\per\second} in contrast to just $128\,$kbps.


Package for inserting TODO statements in nice colorful boxes - so that you won’t forget to fix/remove them. To add a todo statement, use something like \todo{Find better wording here}.


Every once in a while, you might need subfigures in a paper. This package provides a nice solution for it, including enumeration of subfigures and references support. To add a subfigure, use something like this:

\subfigure[Second figure.]{...}\\
\caption{Three subfigures.}


THE drawing markup for latex. It’s easier than most other markups I have seen so far and important if you want to use R’s tikz device (as described later). The figures generated with tikz integrate nicely into the document and look like being set with LaTeX. An example Markov Chain:

\begin{tikzpicture}[node distance=20mm,
    % The shape:
    circle,minimum size=8mm,rounded corners=3mm,
    % The rest
% draw the nodes
\path (0,0)  node (A) [state] {A}
      (4,0)  node (B) [state] {B}
      (2,1)  node (D) [state] {D}
      (2,-1) node (M) [state] {M};
% draw the transitions
\draw [->] (A) to [bend left=15] (D);
\draw [->] (D) to [bend left=15] (A);

\draw [->] (D) to [bend left=15] (B);
\draw [->] (B) to [bend left=15] (D);

\draw [->] (B) to [bend left=15] (M);
\draw [->] (M) to [bend left=15] (B);

\draw [->] (M) to [bend left=15] (A);
\draw [->] (A) to [bend left=15] (M);


Not the easiest algorithm package, but maybe the most powerful. Strange syntax, really, but nice for Pseudocode. An example taken from the manual:

  \KwData{this text}
  \KwResult{how to write algorithm with \LaTeX2e }
  \While{not at end of this document}{
    read current\;
      go to next section\;
      current section becomes this one\;
      go back to the beginning of current section\;
\caption{How to write algorithms}


Package for code listings supporting different programming languages, like C/C++, Ruby, Octave, Python, etc. An example from the manual:

if (i<=0) then i := 1;
if (i>=0) then i := 0;
if (i<>0) then i := 0;


Very nice table formatting. Note that you might want to change the arraystretch for tables using \renewcommand{\arraystretch}{1.2} in your preamble. The package also adds new rules (i. e., horizontal lines) for top, bottom, and mid separators. The following listing shows a simple example for a table using the booktabs package:

\multicolumn{2}{c}{Item} \\
Animal & Description & Price (\$) \\
Gnat      & per gram & 13.65 \\
          & each     &  0.01 \\
Gnu       & stuffed  & 92.50 \\
Emu       & stuffed  & 33.33 \\
Armadillo & frozen   & 8.99 \\


A package I use mostly for suppressing hyphenation in certain words. Can do more, as I’ve heard, but I don’t use it. For example, to suppress hyphenation of the word curiosity use \nohyphens{curiosity}


Balances the columns (in a two column page) on the last page, so that they appear of equal length. Taken from the package manual:

[Balancing two column layouts] is done with the command \balance, which should be issued somewhere in the text of what would be the first column of the last page without balanced columns. If it is issued too late, i. e., in the second column, then a warning message is printed that balancing may not take place.


Another nice package, useful for advanced bibliography stuff is natbib, which supports different types of references i. e., \citep for a parenthetical citation and \citet for a textual one.


When writing scientific papers, one often has to deal with tons of acronyms. Apart from simply writing down these acronyms in running text, there are several things to keep track of, i. e., using short or long form of acronym, writing it in full form (long and short) at first occurrence, not introducing typos, changing a custom acronym etc. To ease this pain, the acronym package can be used to define acronyms and refer to those using keys which will be expanded to the actual acronym in short, long (at first occurrence) or whatever desired form. For example, I define some acronyms in the beginning of my document (after \begin{document}) like this:

\acrodef{voip}[VoIP]{Voice over IP}
\acrodef{mos}[MOS]{Mean Opinion Score}

Which can then be used in the text, e. g.:

...was not reflected in the \ac{MOS}, leading to...

You can explicitly use the short form and long form like this:

was not reflected in the \acs{MOS}, leading to

Example LaTeX file

The following listing just concatenates all packages above and adds some configuration candy to it into the well-known preamble. You could use it as a template for new latex papers, etc.

% specify your documentclass here [report|article|...]
% \documentclass[a4paper,draft]{article}

% for nicer tables
% use package

% version 1 of siunitx package
% version 2 of siunitx package


% objectstyle1, objectstyle2, and important line are defined by personal preference
    objectstyle1/.style={rectangle,minimum size=6mm,%
    rounded corners=1mm, draw=black, very thick, text centered},%
    objectsyle2/.style={rectangle,minimum size=4mm,%
    rounded corners=1mm, draw=black, thick, text centered},%
    important line/.style={thick}%

% some settings for nicer tables

The main matter of the document could then continue like that:

\title{And Now for Something Completely Different}
\author{Eric Idle}


Is your wife a...``goer''... eh? Know what I mean? Know what I mean? Nudge nudge.
Nudge nudge! Know what I mean? Say no more...Know what I mean?


Very small, very non-sense. To get an idea of how LaTeX works, simply copy above two sections into a text file and save it with the extension .tex into a new folder, we will also refer to as the project folder.
Read on for further detail!