Small Makefile script for making daily course notes on LaTeX

I have a habit of making daily course notes using \LaTeX (Probably not the most suitable way for you readers). By using this Makefile script I can automatically generate date based \LaTeX file, and avoiding overriding the current date notes.

Because I have an folder structure like this:

  ~/
    study/
        termX/
            course1/
            course2/
        termY/

In this structure I can copy this Makefile to anywhere.

LC = pdflatex
NAME = $(shell date +%Y%m%d)
TEMPLATE = template.tex

all: make

make: $(NAME).tex
    pdflatex $(NAME).tex
    xdg-open $(NAME).pdf

create: $(TEMPLATE)
    if [ ! -e `date +%Y%m%d`.tex ]; \
    then \
        cp $(TEMPLATE) `date +%Y%m%d`.tex; \
    fi; 
    vim `date +%Y%m%d`.tex

clean:
    rm -f *.aux *.log *.out

The usage is very clear, the default is to compile a tex file to PDF.

You still need to write a tex template called template.tex for this to work.

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.