Changing LaTeX headers via a makefile

The way I would accomplish this would be to place the core content in one LaTeX file (say content.tex) and write two wrapper files (say slides.tex and handouts.tex) that incorporate content.tex by invoking \input{content}. Then you could create the appropriate targets and rules in your makefile, one to compile slides.tex and the other to compile handouts.tex


Another way to do this is to use a macro to contain the information you wish to pass, and do something like

pdflatex "\def\MyHeaders{Whatever} \input MyFile.tex"

in your makefile. You'd probably include a \providecommand*\MyHeaders{} line in the main document to avoid awkward errors.


This is the same sort of problem as asked the Passing parameters to a document question; what follows is adapted from my answer there.

Have the target in your Makefile clobber a file that is \input by your Latex document, which should set the header. Don't be fussy about Latex convention: saving characters by using \def makes your makefile easier to read.

For example, let the Makefile have:

HEADERNAME = My Header

handout: echo "\def\hdrparam{$(HEADERNAME)}">params.tex;  latex manuscript

Then manuscript.tex should begin with \input{params.tex}, defining \hdrparam for use in your header macros.