After posting about the version control bundle, I gave it a test spin.
The version control bundle requires GNU awk. If gawk is not installed on your *nix system, this script will do it for you:
#!/bin/sh
#
# installgawk.sh
#
# A bash script to install the latest version of GNU awk. Be sure to set the variables to the desired values.
#
# http://www.gnu.org/software/gawk/
#
# Mark Eli Kalderon 2008-03-22
# Gawk. Change to the desired version if necessary
VER="3.1.6"
GAWK="gawk-${VER}"
# Build directories. Change to the desired directories if necessary.
GBLDDIR=/var/tmp/${GAWK}-build
# Create gawk build directory, but save source files if they exist.
test -d ${GBLDDIR} || mkdir ${GBLDDIR}
test -d ${GBLDDIR}/${GAWK} && /bin/rm -rf ${GBLDDIR}/${GAWK}
cd $GBLDDIR
# Download and unpack gawk source.
curl http://ftp.gnu.org/gnu/gawk/${GAWK}.tar.gz -O
tar -xvzf ${GAWK}.tar.gz
cd ${GAWK}
# Configure and build gawk.
./configure
make
make check
# Install gawk (in /usr/local/bin/). Will prompt for password.
sudo make install
As of version 0.3, the vc bundle supports bazaar, git, and subversion and runs on Windows and unices. Within the vc directory there are subdirectories for each of these cases:
- bzr-unix/
- bzr-windows/
- git-unix/
- git-windows/
- svn-unix/
- svn-windows/
Each of these subdirectories contains a pair of scripts. As I am on OS X and wanted to see how well this would work with git, I used the scripts in git-unix/:
- vc
- vc-git.awk
Copy these to the root directory of your repository. vc is a shell script that extracts version control information and writes it to a new file, vc.tex. vc does this by calling vc-git.awk to process the output of git status and git log. To use these scripts, put the following in the preamble of your LaTeX document:
\immediate\write18{sh ./vc}
\input{vc}
\write18 allows you to call shell scripts when running LaTeX. Most TeX installations has \write18 disabled by default for security reasons. That’s a good thing. Rather than enabling this globally, you can enable this on an as needed basis, by running pdflatex or xelatex with the -shell-escape argument.
vc.tex defines the following macros which can now be used in your LaTeX document:
- \VCRevision current (maximum) working copy revision number
- \VCRevisionMod as \VCRevision, but with an additional note if the working copy contains modified files
- \VCAuthor author of the last check-in operation
- \VCDateRAW date of last check-in in native format of the VCS software
- \VCDateISO date of last check-in in ISO format YYYY-MM-DD
- \VCDateTEX date of last check-in in TeX format YYYY/MM/DD
- \VCTime time of last check-in
- \VCModifiedText contains the note shown in macro \VCRevisionMod if there were modified files. This macro can be redefined by the user.
- \VCModified 0 if there are no modified files in the working copy directory; 1 or 2 if there are modified files. In general you don’t need this macro.
These macros can be called wherever appropriate. I wanted my version control information discretely tucked away in a footer:
\usepackage{fancyhdr}
\lfoot{\tiny{Revision: \VCRevision ; Author: \VCAuthor ; Date: \VCDateISO}}
\cfoot{}
\rfoot{}
The result:

If you want the version control information in draft mode only, Stephan Hennig, vc bundle’s maintainer, suggests using the ifdraft package.
Post a Comment