Tech-note: Typesetting the CVS Revision in LaTeX

A Church in Romania

Say you want to display the CVS revision of your LaTeX document, somewhere in the document.

The obvious solution
You could use the $Revision: $-tag directly, but then you would be facing some annoyances;

  • The dollar signs would make LaTeX go into math-mode, and typeset the text accordingly, which is most likley not what you want.
  • You would also have to accept the fact that the text "Revision: " will appear before the actual numbers. Also not what you might want.

The better solution
Instead, include the following defines in the top of your LaTeX source file:

    \def\version$#1,v #2 #3${#2}
    \newcommand{\CVSrevision}{\version$Id: $}

Usage example:

    ...
    \def\version$#1,v #2 #3${#2}
    \newcommand{\CVSrevision}{\version$Id: mm-replication-wan.tex,v 1.2 2004/06/12 15:37:12 mad Exp $}
    \begin{document}
    {\Large \textbf{Asynchronous Multi-Master Replication over WAN}} \\
    {\large revision \CVSrevision}
    ...
which would render as something in the lines of:

Asynchronous Multi-Master Replication over WAN
revision 1.2

22nd of August, 2004
Martin Adolfsson
 4D415254494E2041444F4C4653534F4E203A29
 The alpha EV6 (21264) processor operates at 463 MHz