LaTeX and typography


A few tips






This page contains various LaTeX and general writing stuff I have collected over the years and wish to share to people who are starting with LaTeX. Most of the advices and links are connected with writing a thesis and are leaning towards engineering, but they are applicable to virtually any document. While I make an effort to periodically check the external links, I cannot be held responsible for their content.

Introduction

LaTeX?

If you had stumbled here accidentally, and you want to know what LaTeX is, read this or an explanation for grandmas. If you are still not convinced, read the piece by Dario Taraborelli where he explains why to prefer LaTeX over WYSIWYG tools (e.g. Word).

Recommended guides

If you are just starting with LaTeX, you might want to use these guides/tutorials:


Tips

This section gives some random tips after you understood the basics.

Fonts



The default typeface of LaTeX (Computer Modern) is great, but may become tedious after some time, hence you should consider other appealing typefaces such as Palatino and Minion. The LaTeX Font Catalogue is a good place to start exploring which suits you most. If you have problems installing Minion Pro, here is a good resource for Mac OS X and Linux.
Changing a typeface is usually straightforward, for instance, Palatino can be activated in just one line:

\usepackage{mathpazo}

Packages

There are numerous LaTeX packages, and the most important are already well known. The package acronym is a must for any longer document and it is not new even to novices.
siunitx is an indispensable package for typesetting units, so engineers have no excuse for not using it. Sadly, for some reason, it's not so popular (at least I haven't seen it in journal and other templates). A tip: put the following in the preamble

\sisetup{per=slash}

in order to have slashes rather than fractions in units, for instance km/h.

todonotes is useful for putting annotations and placeholders for figures. Many engineering or math figures (i.e. plots, diagrams) are usually put after a substantial part of the text is written, so you may want to reserve their places in the text and use them as a to-do list, which can be generated as well.

pdfpages is useful for including PDF files, for instance the cover page of a thesis, which is sometimes generated with another piece of software.

Figures

Figures such as diagrams are an essential component of almost every publication, and their quality must not be neglected. Needless to say, take care of using the same typeface in the figure as in the rest of the document. It's interesting how many people overlook this.

PGF/TikZ is the native way to generate graphics (primarily diagrams) in LaTeX. Its learning curve is quite steep, but once you get the basics, for many figures you won’t look much further. The 560 pages manual is profound with great examples, but a paper in the PracTeX journal contains a short overview and introduction. Here you can find the showcase of TikZ with very good examples which may be modified, so if you find something similar to what you oughted to draw, it might be more feasible to modify an existing example, rather than create one from scratch. An example of a TikZ generated graphics:





Besides its output quality, another TikZ’s advantage is that the source of a figure is embedded directly in a LaTeX document, thus eliminating the need of using another program (everything can be done in your LaTeX editor). Also, containing text matches the font of the document, and it is possible to use BibTeX's \cite{} command directly in the figure!

I also suggest ipe for drawing diagrams and basic figures. It’s free and quite simple to use, and it’s available on Mac, Linux and Windows. It has the ability of directly embedding and running LaTeX code (so you can have high-quality mathematical notations in a drawing, but also easily matching the font with the rest of the text). Check its showcase to see if it fits your needs. Definitely a no-brainer if you have time to spare.

Plots

Please make your readers happy and avoid generating plots from Excel (I have yet to see a plot that looks nice). If you are an engineer, there is no excuse for using mediocre and baby software for this purpose.
This website would not be complete without mentioning Matplotlib, a great Python 2D plotting library which produces publication quality figures in a variety of formats and interactive environments across platforms. Below you can see one example from here:



This example shows a plot with contours, convenient for Geomatics.
Of course, many engineers prefer to generate plots with Matlab. Its PDF export of plots may be cumbersome (due to bounding boxes), so it is better to export plots in the EPS format and load the eps2pdf package in the LaTeX document which converts the input EPS graphics on-the-fly to PDF.
For converting Matlab plots to TikZ consider Nico Schlömer’s project. There is also a similar project with Matplotlib.

BibTeX

A short summary can be found here. On how to choose the proper style.
Natbib is a must for bibliography in LaTeX. Also bookmark and print an excellent reference sheet. If you wish to make your own style consider custom-bib.
For automatic bibliography generation of books from ISBN consider OttoBib and Manas Tungare’s utility. Doi2bib is a similar tool for DOIs.
If you use an external software for generating a BibTeX file (e.g. Papers or Mendeley) you might want to remove notes in order to avoid bugs and having printed unnecessary information in your final document.
Speaking of additional software, a good bibliography reference manager is JabRef, it is open source and runs on Windows, Linux and Mac OS X.
Bi­bla­tex, the complete reimplementation of BiBTeX and LaTeX, is becoming more and more popular. Check some tips here.

Templates

If your university does not have a standardised template for theses (like in case of TU Delft things are improving), and if you do not have time to build your own style, you can find many nice templates around. Also check this article on the blog LaTeX for Humans.
For my MSc thesis I had used the classicthesis package, which is becoming quite a standard nowadays.

The website howtotex.com, run by a student graduate from TU Delft, has various templates worth checking. Also, check other sections on the website.

Tables

Tables are essential in presenting results. They must be readable, appealing, and follow a generally accepted style. The booktabs manual (as the package per se) by Simon Fear is great with the advices for designing tables. The small guide to making nice tables by Markus Püschel is a very nice and short read.

General writing, rules, style and standards

Although aimed at papers, The unofficial guide for authors (at Lulu) by Tomislav Hengl gives more than a few good hints for writing. It includes a nice workflow for creating a publication.
Everyone should read at least something about mathematical notations. The SI brochure, and its 4-page summary are essential references to every engineer. The Elements of Style and the Turabian’s manual are considered as classics. It is good to buy them, new hard copies can be found for less than ten euros.

Various tips


  • LaTeX puts the intersentence spacing after a dot to separate the two sentences. However, dots do not always mark the end of a sentence, for instance in “i.e.” or “Dr.”. In order to have a proper separation in such cases use this:
    i.e.\
    To make your life easier define shorthands:
    \newcommand{\ie}{i.e.\}
    and later use them through the text like this: ..., \ie ...
    Be careful not to use it together with a comma ("e.g.,") (thanks, Hugo).

  • Note the proper intersentence spacing in the reverse case. According to ChkTeX, in LaTeX, whether a period ends a sentence or not, is only based upon the character in front of the period. If it’s uppercase, contrary to the above example, it assumes that it does not end a sentence (LaTeX thinks it's an initial or an abbreviation). Hence use "\@" in order to force an intersentence space:
    The results of the analysis depend on the highest LOD\@. However, ...
    Read more about interword and intersentence spacings here.

  • Use non-breakable space in cases where you don't want text to be split across lines, especially in references of floats, or in titles. For instance:
    Figure~\ref{fig:example}
    Dr.\~John Doe

  • Use a proper dash. In some instances the en-dash ("--") and the em-dash ("---") are a better choice than a hyphen ("-"). While there are no strict rules, a hyphen is meant to indicate the break of a word across lines, and the connection of compounded words (e.g. e-mail, to reverse-engineer). The en-dash is applicable to ranges:
    1--2
    The em-dash is used to replace commas within a sentence where it would work better:
    The three fundamental representations of geographic features---points, lines, and polygons---are ubiquitous.
    To make things more complicated, the minus sign is different from all of the above. Read more about the topic here.

  • Using triple dots like this ... is not advisable because of the incorrect spacing, so rather use \ldots

  • It might not be correct to do so, but in some fonts the ampersand (&) looks nicer if it is put in italic: \textit{\&}. On a related note, check these 16 ampersand designs.


Miscellaneous

Things that do not fit above (some of them may also be outside LaTeX/typography, but still interesting for writers):

My supervisor's Ten Commandments for happily collaborating on a LaTeX document.

For a concise overview of style tips check this out.

The tool Detexify classifies your handwritten symbol and converts it to LaTeX. There is even a free iOS app. How cool is that? This is much better than looking up a symbol in the LaTeX list of symbols (~200 pages).

Examples of nice books typeset with LaTeX (in general there are not many examples around).

Springer LaTeX search lets you search through numerous LaTeX code snippets to find the equation you need.

Lorenzo Pantieri has nice manuals and guides for specific problems in LaTeX, in Italian though, but it might help.

Some useful links related to graphics and colours:


So you need a typeface... - nice flowchart for choosing a typeface.

Books in the Age of the iPad - recommended reading for publishing content for e-book readers.

Periodic Table of Typefaces - interesting list of typefaces.

Typography in ten minutes - nice and short guide to typography.

The League of Moveable Type - nice typefaces.

LaTeX word count - a Perl script for counting words in LaTeX documents.


Questions?

If you have a question it's best to consult Stack Exchange's page for LaTeX.


Acknowledgments

Thanks to Death to the Stock Photo for the photograph used in the header and footer. Very cool project, by the way.