[Tex/LaTex] How to add version control info (to footers say?)

macrosrevision control

I'd like to keep track of revisions to a document and I use version control software for basically everything (SVN by the way, monotonically increasing revision numbers are their own reward).

I want to add SVN tags like $Id$ for example, SVN will then replace this (if the property is set) with the revision's ID. I'd be nice to show this somehow if only so I can keep track of things more easily. Ideally I'd like to have this info below the title, a list of the files that make up the document (a list of these IDs)

I am using subfiles to allow this to span multiple tex files if that helps.

I am hoping for an easy/canned way of doing this.

I'd like to then compile the document a certain way and have none of this info shown.

I did some searches for LaTeX pre-processor (so I could define a constant if I wanted this info for example) but I'd then have to search for displaying info on the front (which can be done, contents pages prove this) and stitch it all together.

I doubt I am the first to want to do this, so rather than reinvent the wheel, I ask you lot.

Best Answer

Did you try a asking a search engine? One of the first links mentions svn-multi, which can do exactly what you want to achieve.

You can get the info from your repository by adding this to your document.

\svnidlong
{$HeadURL$}
{$LastChangedDate$}
{$LastChangedRevision$}
{$LastChangedBy$}

after setting the svn:keywords to HeadURL LastChangedDate LastChangedRevision LastChangedBy.

With \usepackage{fancyhdr} you can then add the info (Repository URL, last revision and time of last commit) like so

\pagestyle{fancy}
\fancyfoot{}
\fancyfoot[OR]{\tiny \href{\svnkw{HeadURL}}{Revision \svnkw{LastChangedRevision}} --- last commit on \svnkw{LastChangedDate} --- page \thepage}
\fancyfoot[EL]{\tiny page \thepage\ --- \href{\svnkw{HeadURL}}{Revision \svnkw{LastChangedRevision}} --- last commit on \svnkw{LastChangedDate}}

Take a look at this article by Mark Eli Kalderon in a PracTeX Journal from 2007, which explains everything nicely.