[Tex/LaTex] Changing LaTeX headers via a makefile

beamermakefile

I recently created a makefile to use with my TeX documents and am quite happy with the discovery. When I create Beamer slides to use in class, I create both a set of slides and a handout to go along with them. I'd like to have a makefile that creates the slides, then changes one or two lines of the header of my TeX file (by uncommenting and commenting perhaps) to create a set of handouts (possibly by generating a new, intermediate TeX file). I'm guessing that a make file can't edit my TeX file, but that would be cool. Is it possible? Thanks!

Best Answer

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.