Tuesday, September 8, 2009

Batch convert EPS to PDF

In Mac OS X, the application Preview will automatically open your EPS files as PDFs and offer you to save it as PDF when you are done. However, sometimes it does not manage to convert to PDF properly. You may then resort to the command ps2pdf

To batch convert several EPS files in your current directory, do the following at a command line prompt:
FILES="*.eps"
for f in $FILES; do ps2pdf -dEPSCrop $f; done

This will convert all your EPS files to PDF and ensure that they are cropped properly. If you actually prefer to use an entire A4 (or letter size) page for your figure, leave out the -dEPSCrop flag.

Sunday, September 6, 2009

Adding a style (*.sty) file to your TexLive LaTeX installation

There are a few reasons you may need to add a style (*.sty) file to your LaTeX distribution manually instead of using the repositories. First, you may have obtained a newer version than the one that exists in the repos. Second, the style file may not even exist in the repos. 

The following works for a TexLive installation in OS X (and possibly other UNIX systems):

sudo mv foo.sty /usr/local/texlive/texmf-local/tex/latex/foo/

where foo is the style file you want to add. Afterwards, make sure you run 

sudo texhash

to ensure that TexLive discovers your added file.