Saturday, November 9, 2013

Be able Include loss-less vector graphics in your Latex document (good).

Be able to select text inside figures with mouse (awesome).

Compile your latex document with figures faster (probably).

Make your files smaller and of higher quality (mostly).

That's it. The rest is up to you!

I see many people still using .eps files from matplotlib in their otherwise nicely formatted Latex document. Forget this. From this post on we use matplotlib figures in .pdf format. It works exactly as with .eps or .png or what else you might be using:

Let's also use pdflatex for compiling (just replace the latex command):

andersx@awesome:~/my_paper$ pdflatex mypaper.tex

This will also compile much faster than standard latex (using, say, .png-files), since you are now including something that is already in pdf-format.

Last two steps are (1) to save your file as a .pdf-file and (2) autocrop the white borders (loss-less). Step one is accomplished using standard matplotlib/pylab/etc. syntax. The 2nd part is done using a tool called pdfcrop (which is already included in you have latex installed). I prefer to call pdfcrop from within the Python script to avoid having to run more than one command each time I make a new figure.
The above is some boilerplate code. The result is: