Some LaTeX tips and tricks

LaTeX is a great tool for writing documents. After you get accustomed to the syntax and not necessarily having a WYSIWYG-editor, the effectiveness of your writing process is likely to increase considerably. Especially, since the final looks of the document and the edited text are separated, it is possible to focus on the content instead of the appearance. The appearance will be professional enough for most applications without having to worry about it.

There are some things that can make your life a bit easier with LaTeX, at least in my opinion. I have gathered some of the smaller tips on this page to for my own memo and to help also others. Unless otherwise stated, the scripts have been tested only under Linux.


There are a couple of ways from tex source to pdf. The first is pdflatex, but I haven't used it much. The main problem for me with it is that it requires the images to be in pdf format, too. The second way is the longer path: tex - dvi - ps - pdf. Typing all the commands separately is huge work, and remembering the required magical words may not be too easy. For this, there is The Makefile. In short, the compilation process it the following.

  1. From LaTeX to dvi:
    1. latex file.tex - the first compilation
    2. bibtex file - if \bibliography command is used
    3. latex file.tex
    4. latex file.tex
  2. From dvi to ps:
  3. From ps to pdf:

To use the Makefile, just type make file.pdf and that's it. If the compilations halts to an error, you can interrupt it by "x + <enter>".

Embedding a copyright claim on a pdf

Sometimes you wish to to your publication on your own web page so that it is more accessible for the public. In most cases, the copyright holders (conference organisers) permit this given that you add some kind of copyright message to the document. You can write the required copyright claim to this file, compile to pdf and then stamp is on the existing document. The text will appear in the top margin of the page. There are at least two ways to apply the stamp:

Copying a subset of bibtex file entries

In my everyday writing I have three different files with bibtex entries: one with the paper entries having the conferences as crossrefs stored in another file, and finally third file with different string definitions, e.g., for US state names. These all are then included in the bibliography command. The main problem is that the files are quite large (the main reference file has about 500 entries). If I now want to send the sources of my publication to someone, I'd need to include the three files in whole or copy the needed entries. After doing the copying a couple of times manually I wrote a small utility called pyBibParser in Python to take of the copying. After you have compiled the original document, there will be an aux file in the same directory containing among other things the list of citations. The script takes the aux file and the original bibtex files as input and tries to determine the set of entries needed by the document. The crossrefs and string definitions make the problem a bit more challenging. After parsing the files, the script produces a file containing only the entries and strings that are needed by the document, and the newly created file can be used in the bibliography command instead of the larger files.

Note that the script works on the syntax I have in my bibtex files (newlines etc), but I cannot guarantee it working with your files.

PhD thesis template

Naturally I wrote my doctoral thesis with LaTeX when the time came. In some universities they provide a specific template for the task to help the students and to make sure the resulting theses conform to certain rules regarding the contents and presentation. In my university this was not the case, they didn't even specify the different sections needed, so basically everybody is just winging it. In our group people were requesting a template from the previous one defending, making their own customisations to it, and then passing it on to the next person. I received the document basis of my thesis also in this way. After finalising the thesis, I decided to make the "template" available.

In the package, there is a Makefile for compiling the whole thing. It differs slightly form the other Makefile on this page as this one includes also the creation of nomenclature list, and some pdf concatenation. I.e., my thesis was a compound thesis that consisted of an introduction and several publications. Because I wanted the publications to look like in the original publication (plus the fact that at least one of them was written in FrameMaker), the easiest way to include them in the final document is to insert them into the correct location within the pdf. Just copy the publications (or create symbolic links) to the subdirectory Publication and set the appropriate page ranges to Makefile and you should be off.

The template has the following properties:

I guess it's just easier if you just check my thesis to see how the end result looks like.

Removing vertical space from bibliography

Sometimes it is necessary to squeeze quite many bibliography entries into a small space. The two most easy way to accomplish this is to use a bibliography style that is somehow condensed, e.g., abbrv, and to wrap the entire reference section into smaller font:

These are not always enough, and you start noticing the huge empty lines between the entries. These can also be removed, but be warned, the readability of the result suffers. The trick is to redefine the thebibliography environment with smaller vertical spacings in the preamble of the document:

SVN and LaTeX integration

Sometimes it is useful to put the document in writing under version control (though personally the first time I did it was with the dissertation). When the document is under SVN version control, it is possible to get some automatic versioning info embedded to the text itself. The whole thing can be accomplished by the following steps:

  1. Create a repository:
    svnadmin create repo_name
  2. Add a subdir:
    svn mkdir file:///path/to/repo/thesis -m "comment creation"
  3. Enable keyword substitution:
    svn propset svn:keywords 'Id Author Date Rev URL' *.tex
  4. Add the tags to the document, e.g., in the starting headers:
    $URL: $
    $Date: $
    $Revision: $
    $Author: $
    $Id: $
  5. Add file to version control
    svn add file_name
  6. svn commit
  7. svn update

Basic document template

This can be used as a plain document template. It should be noted that the file has to be compiled with latex->dvips->gs and not with pdfLatex.

black dot

Valid HTML 4.01 Transitional -- paulus - 16.2.2010