Read my book

I wrote books about Webpack and React. Check them out!

Saturday, October 2, 2010

Getting Most Out of LaTeX

I have been using LaTeX, the greatest typesetting system ever, quite a bit during the last few years. I can't imagine going back to WYSIWYG office suites even though I must admit I use Google Docs for some smaller tasks.

I guess the thing that makes LaTeX so great is its versatility and relative easy of use once you get around the initial learning curve. I suppose the greatest thing about LaTeX is that it allows you to forget various nasty details (style, fonts, paging, ...) you would have to fiddle around with otherwise.

In this post I am going to show you various little tricks I have picked during my years using LaTeX. I'm not claiming to be absolute LaTeX guru, I still have to check out how to do certain things every once in a while, but I hope this post manages to be of help to someone. :)


I have grown quite fond of Kile. I did try using Texmaker for a while but Kile seems to do the job well enough for me. I also recommend checking out LyX in case you want more graphical tool to use.

Of course hard core users will just fire up their favorite editor (emacs, vim :) ) and be done with it. There are also various macros for these editors that help: AUCTeX, VIM-LaTeX. I haven't personally tried them out, though.

In addition you are going to need some sort of compiler. Windows users should give MiKTeX a go while Linux peeps may find TeX Live handy.

I won't go into detail about compiling. Provided you use some of the aforementioned LaTeX editors, this should be relatively painless.


BibTeX is easily one of the most useful tools available for LaTeX. It allows you to manage your bibliography entries in a simple manner. Pretty much all you need to do is to list your references in a certain format and then cite using the reference id. It will handle the rest.

Custom Bibliography Format

Most importantly this makes it easy to change the bibliography format. You can even generate your own custom format using makebst should you want to.

Graphical Frontends

There are various graphical frontends (JabRef, KBibTeX) for editing the BibTex database. Given BibTeX format is native for Lua you could even whip up one yourself. :)

Getting Away Without Using a Frontend

I have noticed that in practice you rarely need to use a frontend, though. This is particularly true in case you are dealing with books or scientific papers.

It is easy enough to generate BibTeX bibliography entries for books using OttoBib. Just provide ISBN and OttoBib does the rest. All you need to do is to check out the output and copy it to your reference file.

In case of scientific papers you can configure Google Scholar to return BibTeX entries. Just check out the preferences and you should find the setting to enable BibTeX output.

There are times when the paper you are after won't be found using Scholar. In this case you may be better off using alternative service such as CiteSeer.

Those using Mozilla Firefox may find Zotero to be most useful for maintaining their references. Apparently it provides BibTeX output as well.

Maintaining Document Structure

As you write your ingenious thesis or whatever using LaTeX you will soon notice it starts to get a little bit cumbersome as the file size grows. Fortunately LaTeX makes it possible to manage the mess.

Pretty much all you need to do is to use "input". Just define a master file, split your document to sensible parts (ie. file per chapter) and input the parts within the master file (ie. \input{some_file.tex}). This article covers various additional commands.

Besides splitting the document up you might want to define some macros. If you notice you are repeating some specific task over and over again, it's definitely a macro time! Defining one is simple. The command "newcommand" is there for that. Thank you Captain Obvious!

For instance to define a new command to render a tabular newline with a horizontal line after it, you could do something along "\newcommand{\tnhl}{\tabularnewline\hline}". After this you can call the new command using "\tnhl".

Handy Packages

More often than not the functionality you are looking for is already within some package. CTAN lists these.

I won't go into particular detail in this part. I guess it suffices to say that check out Beamer, or better yet yml2tex. Writing presentations couldn't really be any simpler than that! :)


I'm quite sure there are a lot of handy LaTeX tricks out there. I just hope I managed to cover some useful ones. :)