Friday, November 1, 2013

Latex and track current version of a document

I wrote a lot of stuff on latex. But any stuff when I have to send it to someone who will revise it every time became pain in the butt, bcoz someone cannot distinguish one version from another. So I made a solution...

I think every one know how to add SHA1 id from git to c/c++ define to distinguish one binary from another, but how I can do it with text file? I use Makefile to build pdf from sources. So I can add simple sed script to find particular string and fix it with current date. The Code

TEX2DVI = texi2dvi

TEX_FLAGS = --dvipdf

AUTOREF_ALL =   \
                general.tex             \
                autoref.tex

DATE = `date +%d.%m.%y`
STR = "s/{..\...\...}/{$(DATE)}/"


autoref: ${AUTOREF_ALL}
        @sed -i $(STR) general.tex
        ${TEX2DVI} ${TEX_FLAGS} autoref.tex

.PHONY: clean

clean:
        rm -f *.log *.aux *.toc *.pdf *.dvi *.bbl *.blg



and string from my general.tex

\vspace{\baselineskip}
\vspace{\baselineskip}
\noindent\centerline{02.11.13}
\vfill




And now it will fix the date everytime when I'll build pdf from soures!


PS
ofc it's all working under Linux. But I'm sure you an path it to make it works under Cygwin/Minigw/other *nix.

No comments:

Post a Comment