LaTex Makefile with TexShop

Today I wanted to change the build process of my LaTex project in TexShop. First I thought, that there must be some kind of script within TexShop that I could change but it turned out that this is not the case. After some research, Lars told me that using a makefile would be the tool of choice to solve this issue. Since this was not as easy as I first thought, here is a little tutorial on how I finally solved it.

Makefile for building LaTex projects

The following Makefile solves the following issues, often faced in LaTex projects:

Building the BibTex bibliography

Creating index

Building table of contents

Since TexShop uses pdflatex for creating pdf output, I used pdflatex in the Makefile. Please remind that the Makefile repeats the call to pdflatex until all these issues are done.

Please remind that you have to set the name of your main .tex file in the second line of the Makefile. After that, you can either add your latex bin directory (/usr/texbin on my machine) in your $PATH variable or you have to use absolute paths in the TEX macro within the Makefile.

Setting up TexShop to use Makefile

The next step is to set up TexShop to use your Makefile instead of directly using pdflatex. Since I have an older version of TexShop, things might differ a little from newer versions, but for me the following steps worked out fine:

Go to TexShop -> Settings dialog

In "Miscellaneous" tab set "make" as personal script within "LaTex program"

Save settings

Put the little script below into your /usr/texbin directory and make it executable

This script should call the make command within your current working directory which is all you need to build your LaTex project:

#!/bin/bash
make

Notes and Credits

Even if I'm ashamed to admit that - this was my first Makefile ever. So if you have any ideas on how to improve it, please leave some comments. Lars send me the first draft of the script and I mainly removed some lines of code that I did not use - so basically it's Lars's script.