Timestamp your LaTeX Documents

posted in: LaTeX, Technicalities | 2

While working on a somewhat larger scale document I always end up with numerous prints, .dvis, .pdfs and so on and so forth. Once, I lost all my original .tex documents and thus had to copy everything from a pdf and reformat it. In a case like that, it sure is handy to know exactly with which version you are dealing and which one is the latest. So for my thesis I wanted to add a little automatic timestamp to each print. Sure enough I found timestamp.sty. Just go to your local package repository, create a folder called <timestamp> and save timestamp.sty into it. With

\usepackage{timestamp}

in the preambel and

\timestamp

anywhere in your document, you can then add the – you’re guessing it – timestamp. The output will look like this:

2007-03-23 14:34

Now, I never liked this date format, so if you, too, prefer DD-MM-YYYY, open timestamp.sty and scroll to the very bottom. Replace

\newcommand{\timestamp}{\the\year-%
\ifnum\month<10 0\fi\the\month-%
\ifnum\day<10 0\fi\the\day\ \xxivtime}

(the last three lines above \endinput) with

\newcommand{\timestamp}{\ifnum\day<10 0\fi\the\day.\,%
\ifnum\month<10 0\fi\the\month.\,%
\the\year\ — \xxivtime\,h}

\timestamp then produces

23. 03. 2007 – 14:34 h

However, the version I use looks like this:

\newcommand{\timestamp}{compiled on \ifnum\day<10 0\fi\the\day.\,%
\ifnum\month<10 0\fi\the\month.\,%
\the\year\ at \xxivtime\,h}

So the output reads

compiled on 23. 03. 2007 at 14:34 h

2 Responses

  1. Dominik Wujastyk

    Thanks, this is very handy! You should put it into CTAN.
    Best,
    Dominik

  2. Thanks Dominik, glad you find it useful. As for CTAN, Timestamp is already in there, and I feel merely changing the output format is not adding enough to justify a new packet. Take care!

Leave a Reply

*