Version control using RCS, CVS or Subversion

If you use RCS, CVS or Subversion to maintain your (La)TeX documents under version control, you may need some mechanism for including the version details in your document, in such a way that they can be typeset (that is, rather than just hiding them inside a comment).

The most complete solution for RCS and CVS is to use the (LaTeX) package rcs, which allows you to parse and display the contents of RCS keyword fields in an extremely flexible way. The package rcsinfo is simpler, but does most of what you want, and some people prefer it; it is explicitly compatible with LaTeX2HTML.

If, however, you need a solution which works without using external packages, or which will work in Plain TeX, then you can use the following minimal solution:

\def\RCS$#1: #2 ${\expandafter\def\csname RCS#1\endcsname{#2}}
\RCS$Revision: 1.498 $ % or any RCS keyword
\RCS$Date: 2007/11/05 22:31:23 $
...
\date{Revision \RCSRevision, \RCSDate}

If you’ve entered the brave new world of subversion, the package svn may be for you. It has explicit cleverness about dealing with dates:

\documentclass{<foo>}
...
\usepackage{svn}
\SVNdate $Date$
\author{...}
\title{...}
...
\begin{document}
\maketitle
...
\end{document}

will (once subversion has committed a copy of the document) cause \maketitle use the date that has been written into the $Date$ keyword.

The alternative is the svninfo package, which has much the same mechanisms as does svn but with a rather different focus. Svninfo does the date trick that svn performs (controlled by a package option), and can set up page foot-lines using package fancyhdr. There isn’t much to choose between the two packages: you should read the packages’ documentation to see which you find best.

rcs.sty
macros/latex/contrib/rcs (gzipped tar, browse)
rcsinfo.sty
macros/latex/contrib/rcsinfo (gzipped tar, browse)
svn.sty
macros/latex/contrib/svn (gzipped tar, browse)
svninfo.sty
macros/latex/contrib/svninfo (gzipped tar, browse)

This question on the Web: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=RCS