Top 10 LaTeX modules


Hi all! I've lately been forced to play around with LaTeX again for helping to write up a course script. Doing so, I noticed that there are a couple of really useful packages out there that are not being used as often as I feel they should. Hence, I'd like you to present my personal top 10 LaTeX modules which I use basically everyday and which have proven extremely helpful.

The canny among you may notice that I didn't manage to restrict myself to only ten packages; it's 13 in the end, and I promise they're all worth mentioning! Let's have a look...

Typesetting

KOMA-Script

One high-quality LaTeX package. KOMA-Script provides alternatives for the classical LaTeX document classes article, report, and so on. Its goal is to actually overcome the limitations imposed by the traditional document classes, for example when it comes to the page dimensions. Anyone who has ever used article on an A4 page will have noticed that the text width comes out somewhat narrow. This is probably because article's sizes where designed with US-formatted paper in mind. Workarounds are typically the use of the "a4wide" package (which is highly discouraged by the way, see the LaTeX taboos), or setting the geometry of the blocks oneself using the geometry package. -- This is however quite MS-Wordish, and should really not be done. The scrartcl class (of KOMA-Script) brings remedy here by providing a native option indicating the page size. You'll notice that everything comes out quite nicely, without further customization or margin fiddling required. Hurray! As a matter of fact, I'm not using the traditional classes anymore at all nowadays. And I bet that you, once you tried KOMA-Script, won't either.

Latin Modern & T1 encoding

When typesetting documents which include more than the standard 26 letter English alphabet (e.g., accented characters such as "Ü" or "è"), the alert TeX typographer in you might actually notice imperfections in the way TeX treats those.
The fonts that were originally distributed with TeX have only 128 glyphs per font and therefore do not include any accented characters as individual glyphs. Instead, all such glyphs have to be constructed using the \accent primitive of TeX or by similar methods. -- The LaTeX Companion, Second Edition
The encoding of such fonts is OT1 (LaTeX's default), and it actually leads to inferior kerning and hyphenation with accented characters. The T1 (Cork) encoding tries to take over at that point by by enabling TeX to typeset over 30 Latin character based languages correctly. Making use of that is as easy as \usepackage[T1]{fontenc} You may notice that LaTeX's standard font (Computer Modern) is only available OT1-encoded (TeX's standard). This makes TeX spit out ugly bitmapped fonts with T1 encoding by default. To overcome this, you could load the alternative Latin Modern Fonts (LM) which have been created as an extension of the CM for (not only) all sort of accented characters. Hence, try out \usepackage{lmodern} \usepackage[T1]{fontenc} to have TeX nicely typeset accented characters.

The microtype package

A package for the real hairsplitters (aka LaTeX power users). It improves the appearance of written text blocks in very subtle ways, using such fancy techniques as
  • character protrusion,
  • font expansion,
  • adjustment of interword spacing,
  • additional kerning,
  • hyphenatable letter spacing (tracking), and
  • the possibility to disable all or selected ligatures.
In case you're not interested in the details: Never mind! Just do a \usepackage{microtype} in the header of your document, and it will just look better™. Great.

Graphics and figures

TikZ/PGF

If you want to do graphics in LaTeX, you can use many different packages. The era of Postscript spawned the now almost canonical pstricks, for example. Nowadays, the standard output format of (pdf)LaTeX is, well, PDF; and it seems that this standard would gain the upper hand over Postscript in general (given the fact, for example, that Adobe's Postscript documentation is published in PDF). There do exist workarounds for including pstricks into PDF, but none of these is really compelling. The need for a modern graphics package is answered by TikZ/PGF. Like pstricks, this package is so huge that basically everything that you can imagine is possible, and thanks to the well-thought user-interface easily so. The 500-pages manual (which is probably the best manual for a software that I have ever read) gives you a complete overview and is full of nice examples. See also TikZ and PGF examples on Kjell Fauske's beautiful website.

pgfplots

If you want to do function graphs in TikZ, then pgfplots is for you. It abstracts even further from TikZ by providing an interface that lets you say "give me axes of these sizes, with that function in it". This way, you can reach in three lines of code what what would otherwise take 20 in pure TikZ. -- Of course, all features that sit in TikZ are automatically included into pgfplots. Like all extraordinary LaTeX packages, it's backed by an excellent documentation, too. And by the way: there exists a converter for MATLAB figures, too.

subfig

Ever had two graphics next to each other in a float? Then you probably did something like

\begin{figure}
\centering
\begin{tablular}{cc}
\includegraphics{...} & \includegraphics{...}\\\\ (I) & (II)
\end{tabular}
\caption{(I) blabla. (II) blabla.}
\end{figure}


Such monsters are no longer necessary, thanks to the blessings that subfig brings to us. Just go like

\begin{figure}
\centering
\subfloat[][]{\includegraphics{...}\label{fig:1}}
\subfloat[][]{\includegraphics{...}\label{fig:2}} \caption{\subref{fig:1} blabla. \subref{fig:2} blabla.}
\end{figure}


 -- The subfigures get automatically numbered as (a), (b) and so on, you can give them a tiny little individual caption, and when you cite them as \\ref{fig:1}, for example, then you'll get a "figure 1.2a" in return. It couldn't be any easier.

Miscellaneous

hyperref

The eierlegende Wollmilchsau among the LaTeX packages. It provides you with proper line breaking with URLs, makes inner-document links for the output PDF (such as from a citation to the reference block), and adds a PDF table of contents. Simply indispensable if you plan to publish your document not only in printed form.

booktabs

LaTeX does a great job helping you typeset text, but with tables the user can still make things look quite nasty. The booktabs package manual contains some nice and crisp layout recommendations, and -- hurray! -- the package itself provides the means to follow them.

listings

When trying to have source code in typeset by LaTeX, many users will probably use the verbatim environment or -- worse -- go like \texttt{source code}. None of these workarounds are needed anymore with the advent of the listings package in your LaTeX header! listings provides you with an inline and a blockset environment, does syntax highlighting for a plethora of languages (while adding new ones is trivial, really), and gives you thousands of options (for example, if and how to print line numbers in the code). If you want to show off your source code, listings is your man.

lipsum

Now, this is rather more for the impatient among us. When starting to write up a new document from scratch, you'll maybe want to check out its approximate final appearance before you've actually written the first line. Many people will probably do something like

\documenclass{scrartcl}
\begin{document}
adsa fsdaf sdagdghgd tfghsdg sdg sdoig jaeofi
\end{document}


to fill up the lines. If you are sick of typing and you don't want to mess up your LaTeX sources, use the lipsum package instead. This

\documenclass{scrartcl}
\usepackage{lipsum}
\begin{document}
\lipsum
\end{document}


will print a lengthy and meaningless text (the lorem ipsum) that actually looks like real text. Plus, it's merely one line of code! The above example on KOMA-Script contains some of it, too.

algorithm2e

There are a couple of ways for nicely typesetting algorithms in LaTeX, see for example the algorithms or the algorithmic package which both belong to the same package. Personally, I prefer algorithm2e (just like here, by the way), because its output is particularly clear and easy to read. Indeed, the module hasn't been updated for a couple of years now, but it certainly still does a great job.

ntheorem

Written as an extension of LaTeX's very own theorem environments, it aims first of all at
  • providing a consistent placement of theorem end marks (such as tiny diamonds at the end of an example) that also work if the last thing in an environment is a (math) environment, and
  • the possibility to automatically generate a list of your environments.
Personally, I came for the end marks but I stayed with it for the nice default layout of all the generic environments. Try \usepackage[amsthm,amsmath,thmmarks]{ntheorem} (the ams* options are set for compatibility), and see if it convinces you, too.

natbib

The natbib package provides a single, flexible interface for most of the available bibliographic styles. It gives you more flexibility when actually displaying the citation (such as customized type of brackets). Most interestingly, too, is the fact that natbib's bibliography styles are effectively able to handle URLs in citations. This actually enables you to cite a website from LaTeX. Put \usepackage[numbers]{natbib} \bibliographystyle{plainnat} in your header and enjoy!