Document Version Numbering in Latex

October 17th, 2011

How useful would it be to include a document version that can increment itself every-time the document file is updated into a subversion repository. Being able to show a revision number on selected pages of Latex documents must prevent the confusion that arises during project documentation as both project and documentation evolve. It is easy enough for the document author to track revisions (embedded in comments) but being able to actually print out a dynamic revision is much more difficult.

Example document version numbering

Example of a document with version number

The idea for this came from an article by Lex Spoon who provided the basic Latex technique for providing a variable that could be rendered and a perl script. Here I will outline a similar solution using python, extending the concept somewhat.
  1. provide major & minor version numbers in a file
  2. use a subversion tool to determine the last commit revision to the current folder or tree
  3. combine the version and revision numbers to make a definitive version reference
  4. save this (and any other information you want) to a TeX file as \newcommand\svnversion{1.2.345}
  5. include this file in the preamble of your main LaTeX document
  6. you can then reference the version anywhere you wish with the variable \svnversion
Lex Spoon provides a perl script which automates this for you, possibly integrating with your build process; my python script (which uses pysvn) has more mundane ambitions and is available on the AFC Commercial OSS download site. To get this working:
  1. download the script from the site and copy it to somewhere in your path e.g. /usr/local/bin
  2. make sure you have the pysvn module installed; download form if not
  3. go to where your LaTeX document is stored; it should be in part of a subversion tree
  4. create the file sversion.txt to contain the major minor number of your project e.g. 1.2
  5. now run the script sversion (or whatever you called it in step 1); this should create a local file sversion.tex
  6. in the preamble of your LaTeX document add a line like \include{sversion}
  7. you should now be able to use the variable names like \svnrevision and \svnversion to render appropriate numbers
  8. simply run sversion at any-time to update the version numbers
You could even move the files into a more global location for the project and run sversion in that folder.

Oracle XE on SuSE

June 12th, 2011

Today it became necessary to deploy Oracle XE on a new SuSE system. This did not seem a big deal; we had already deployed a version of Oracle 10g XE on SuSE 10.2 quite a while back and as far as I remembered it was a simple rpm deployment. This time the XE was the same but we were deploying on OpenSuse 11.2.

Everything seemed to install fine, but darned if Oracle would not come up at all with no errors logged anywhere to give us a clue. We paused to wonder; perhaps the versions of glibc and libaio (stated as requirements) were too new - should we revert to something older? As it happens we had to deploy Tomcat v6 with Java v1.6+ and our normal alternative - Centos/RedHat - had only prior versions of these. So it was either go back to RHEL v5 - requiring an upgrade to Java/Tomcat - or figure out what was wrong and get the SuSE system working.

It was Friday; plan B won - but it took us quite a while to figure out what was going wrong!

The Problem

First off we downloaded the XE rpm version from Oracle's website then installed it using the rpm command
rpm -ivh oracle-xe-univ-
It did complain a bit but these were warning messages because the startup script in /etc/init.d was missing a few presets expected by SuSE system configuration.
 blacktav:/srv/ftp/Oracle # rpm -ihv oracle-xe-univ- Preparing... 
########################################### [100%] 1:oracle-xe-univ 
########################################### [100%] Executing Post-install steps... 
insserv: warning: script 'oracle-xe' missing LSB tags and overrides insserv: Default-Start 
undefined, assuming default start runlevel(s) for script `oracle-xe' oracle-xe 0:off 1:off 
2:off 3:on 4:off 5:on 6:off You must run '/etc/init.d/oracle-xe configure' as the root 
user to configure the database. 
These extras were not needed as the service was configured to start-up correctly and the LSB component is just documentation to describe the product. All seemed good.
  1. an oracle user account & group had been added as oracle
  2. the product tree had been populated under /usr/lib/oracle/xe
For convenience at this point we added entries in /etc/ (oracle.conf) to add the Oracle libraries and in /etc/profile.d ( to add Oracle binaries to our path and a few convenience variables for Oralcle such as ORACLE_HOME and the likes. These steps are also detailed in the Oracle Installation Guide. And so to the final step, doing the configuration step with
/etc/init.d/oracle-xe configure
This step should initialise our database file and actually launch both the SQL engine and Oracle's management webtool servers. We were expecting to use this in the wild, wild Interweb so we decided to provide a difficult password for the system users; we accepted defaults for the other values. This interaction creates a file in /etc/sysadmin (oraclexe.conf) which is a reference for configuration information by the startup script. This "seemed" to complete without error but something was not right; neither the engine nor the admin web application were running. All Oracle had said was:
Starting Oracle Database 10g Express Edition Instance...Done Installation Completed 
Successfully. To access the Database Home Page go to ""
Oracle had not installed itself at all - there was no oradata/XE tree, nor other folders which the various conf/scripts should have created. t took us quite a while to figure this one out; what seems to have gone wrong was that the oracle user account had been created with a password. When we assigned a password during the interaction, this password was used to initiate an su session when the database was actually configured by the oracle user. Because the passwords were now different, su could not work and the script did not have sufficient privileges to create the folders required. There were other issues around simply running sqlplus; depending on our trial: libaio was missing, the binary was not in the path or ORACLE_HOME was not set.


Anyway we eventually figured it out. This is what we should have done:
  1. make sure you have the required libraries (glibc and libaio); you might need a 32b of libaio if you are installing a 32b application on a 64b platform
  2. install using the command
    rpm-ihv oracle-xe-univ-
  3. set the oracle user's password to "oracle" with passwd oracle
  4. in /etc/profile.d add an file in which you can add the lines
    export PATH=$PATH: export ORACLE_HOME 
  5. log off and on again so these exports can take effect. Before continuing, make sure you can startup sqlplus
  6. now you can finish off with /etc/init.d/oracle-xe configure; accept the defaults and when prompted for a password use "oracle"; your system should pause displaying
    Configuring Database...
    after a few minutes it should finish and you should have a working Oracle instance which you can check by going to If you have started an installation and reached a point where it has failed like above; it should be possible to remove oraclexe.conf from /etc/sysconfig and try again from step 3.


There are essentially two steps to be completed: install from rpm and configure the application. In order for the configuration step to succeed you need to ensure:
  1. the sqlplus tool can be started from the command-line
  2. the configure script can su to the oracle user account using the password provided
For whatever reason, neither of these are satisfied by the tools or the process documented by Oracle Security Alert: once installed, remember to change the oracle user password to something more secure: the default is obviously widely known.

Running an X-app without an X-server

March 15th, 2011

Hmm, I suppose this sounds like a really daft thing to do - why would you want to run a graphics application on a system without a GUI? Here are a few use cases:

  1. you manage a remote Unix server hosted abroad and of course it is headless and has no use for a Graphics environment
  2. you do have a full-blown Desktop system which has a working Xserver but for some sessions - possibly spawned by a root process - there is no access to the Xserver; you can emulate this with the following sequence entered into an xterm:
    su -
    su - username
    i.e. su to root and then to another user - this final session will have lost access to the Xserver
  3. you need to run a graphic tool designed to be called from the command-line; it still needs a GUI environment because it requires access to GUI elements perhaps to generate a graphics file. Lazy programming? Maybe, but that does not fix your problem

In my particular case I needed to run a command that need a GTK environment to generate a graphic image; the command was launched from a Zope application which in turn had been launched as a root service and ultimately it was designed to be run as a facility on a webserver. So I was hit by all these issues.

Ordinarily it should be possible to address issue 2 with some trickery with xhost and Xauthority but even this seems to be non-trivial. I had already identified Xvfb-server as a long-term solution to the first problem and fortunately those good folks on the Interweb were able to point me at a complete solution which does not even require an X server to be running all the time. Instead a virtual server can be created on the fly and brought down when it is finished with. All achieved by the script


Kudos to darvasan for getting this together and making it easily available. On my SuSE 11.3 system, the script failed to run complaining with

mktemp: too few X's in template `Xauthority'

which was resolved by editing the script as follows:

- AUTHFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" Xauthority) 
+ AUTHFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" Xauthority.XXXXXXXX)

Kudos for that one goes to olesen, an almost anonymous dude on Red Hat Bugzilla.

So having installed the Xvfb server you can now execute the following:

xvfb-run some-daft-gui-script

and provided your script finishes cleanly and doesn't get stuck in a GUI dialogue, you are back at a prompt.


A Cautionary Tale

February 3rd, 2011

On Friday, we were asked to review a technical problem a neighbour was experiencing. It turned out that a MySQL server had somehow corrupted its data-file during a power-cycle. Although the user thought they had been backing up their data, what was actually being saved was a snapshot of their database from 2007. The upshot being that their database - in daily use since 2007 - was now hosed. The more the system was investigated, the greater the probability that their data was lost for ever. While it is embarrassing to lose your database, to lose it because your backup was useless is verging on the criminal. Laugh or snigger if you want but before you do, make sure

  1. you have a backup strategy
  2. and a disaster recovery plan
  3. and most important of all, make sure they all do what they are supposed to do


Bash Hackery

January 12th, 2011

This is a cunning one I discovered today thanks to someone called vino. If you are a bash geek, you will already know this and, no doubt, use it every day; sadly I don't hack on bash that often.


Strip-off an extension from a filename in a bash script


First time I solved this, I used sed, which is fine and so full of potential its a shame not to over-complicate it. Today I found this really neat hack

for FILE in *
    if [ -f $FILE ]
      # name without extension
      echo "Filename is ${NAME}"

much more light-weight; the important bit being:


I might even be able to remember this one!

Consulting my Bash reference states that


gives the value of var after removing pattern from the right


SuSE 11.3 Multi-head

November 30th, 2010

On Thursday, I decided to upgrade from OpenSuse 11.2 to 11.3 I was highly suspicious that this would work so bundled up all my important documents, systems, settings & whatever and stored them safely away in my secret place. Downloaded and made a CD from the 64b Network Install ISO and promptly booted my system from the CD. Chose the upgrade option and went and made a couple of nice curries while the beast took 2 hours to download whatever it needed. …and when I came back…. Almost everything was working perfectly!

Better than that, some of the packages I had installed from the Packman repository were flagged correctly and through Yast's Software Management tool I was able to update, remove or whatever any packages that the installer did not know what to do with. And that was it; local applications were working fine, and all my important apps were all brand new and shiny recent versions - even weird stuff I had in /usr/local/bin continued to work fine. Wow! Seriously impressed.

Getting multi-head dual screens to work in OpenSuse 11.3 with a Radeon card

Only one fly in the ointment - almost a disastrous one as well. I have 2 monitors fed off a Radeon card which had given problems before though 11.2 seemed to cope well. But not 11.3 and definitely not KDE. Here's what I had to do:

Support Multi-head

Seems the latest kernel does not support automatic mode lines from RadeonHD cards so this feature should be turned off. Quite simple when you know what has to be done; edit your /boot/grub/menu.lst file and add the switch


to each of your kernel lines. Then just reboot. This allows you to at least choose multi-head behaviour.

Why graphics mode setting has been moved to kernel is beyond me; I would think this will make life much more difficult for folks pulling graphics cards in and out (yes, I have done that in the past) and general graphics issues. But perhaps this is only the start of some grand design thought up by someone.

Anyhow, if you have a Radeon or Nvidia card, this tweak may help you sort graphics problems.

Saving Multi-head Settings

Now I was able to choose the KDE control for configuring my multi-head setup: System Settings → Display After some experimentation, this was fine. But as soon as I logged out and back in again, the settings were lost. Here's what you can do:
  1. As before, configure your display as required and leave the configuration tool
  2. at this point, the settings have been saved in
    as a set of xrandr commands
  3. you can test these settings by logging out and in again and then running this script
  4. what we really want to do is execute this script as we login; presumably KDE does attempt this but if the X session is not ready, then nothing happens. We could add it to our profile or .bashrc, but then it would execute every-time we opened a terminal. Instead add a link to the script in
    then it will execute as KDE comes up for your user's account

Of course, this is only a workaround for KDE which should be doing it for us; if anyone has a better plan, please let me know.

Despite this minor hiccup, I am loving OpenSuse 11.3 - it actually feels quicker and more responsive than 11.2 and several tools that I use all the time have improved dramatically. Well done the Suse team on delivering such a painless upgrade!


Home Sweet Home (in 3D)

November 30th, 2010

Actually, what prompted me to upgrade my system recently was Sweet Home 3D.

Sweet Home 3D: an interior design application

Screenshot of Sweet Home 3D

This is a Java application suggested on ILUG (pointing to as a tool to help design floor layouts; other CAD-like applications were recommended too but this one seemed to be exactly what I wanted - just draw simple floor layouts with or without furniture. And as an added bonus, it creates 3D walk-throughs for you as well. Cool indeed.

Problem was, although it would startup on SuSE 11.2, it whinged bitterly about some GLX library that did not fully support ATI cards in its 1.2 incarnation. Upgrading my SuSE provided v1.3 of the particular library and right now I am happily making 3D plans or our house, the office and a rather futuristic Work-in-Progress that Kevin McCloud will definitely want to see!

Of course, being Java, it will also work on Macs.


Web Page Performance

September 3rd, 2010

It can be really difficult trying to quantify what a “slow website” really means. Its easy to spot a slow site but arriving at some metric that helps you monitor attempts at improving performance or better still, a tool which actually makes some sensible suggestions…

Firebug and Page Speed

Using Firebug and Page Speed to test page loading

Well, now there is one by using a combination of Firefox addons:

FireBug - a general web developer type of tool

PageSpeed - an addon addon that not only measures page loading performance but gives you several suggestions on what could be improved and also what is working well

I am told that Google are now using performance metrics in their page scoring so these tools can even help your SEO efforts. If you are also trying to monitor the effects of a caching tool such as Squid or Varnish or even Apache in front of your website then also add

livehttpheaders - gives detailed info on objects downloaded and can help monitor cache hits

to your list of Firefox addons.


IPv6 on openSuSE

August 31st, 2010

We are fortunate to have several of our servers hosted by Hetzner in their data centres in southern Germany. Since 2009, all Hetzner systems could have IPv6 connectivity, all you had to do was ask for a subnet and you would receive a /64 subnet allocation and a gateway address; these might look like this:

IPs: 2a01:4f8:145:4243::/64
Gateway: 2a01:4f8:145:4240::1 /59

Search for Posts
Popular Tags
Recent Comments
As you mention, it is true that an unregistered record cannot be used in the (Select *) method of setting ...
© 2013 Andy Ferguson