Including Git Revision Identifiers in LaTeX


In the last couple of years, LaTeX software has become very popular for the production of technical and scientific documentation. This is a high-quality typesetting system which is available as free software. The majority of LaTeX source files are under the revision control system Git. Git is additional software, and it allows you to do many things, but keep in mind that Git doesn’t modify source files, while other systems do. For instance, you can ask Subversions to replace the placeholders $Revision in the committed source file with the latest revision number. This is a handy solution for presenting figures and dates in your LaTeX documents.

Git’s representatives often state that any type of modification of source file is pure evil. This feature is absent from Git, and every betokens moral corruption. In this case, the client’s program, which is LaTeX, is responsible for any modification and revision information in the output. Git only makes this information available, but it doesn’t change the source. Stephen Henning’s vc batch contains a number of scripts that extract modified information from different version control systems, involving Git, and make it available as LaTeX macros. In this case, we use vc.tex to take information and the primary LaTeX source file remains untouched by Git.

post3aWe have another rule, which might be interesting, and it involves running git code to produce vc.code. But, the hardest thing for people is to get the dependencies right, and we will break down this entire process. The input file vc.tex needs to be regenerated whenever it predates the last commit. If you have a good understanding of Git internals than the command that requires the modification of time .git/logs/HEAD, should provide you are the reliable timestamp for the last commit. You can make a rule for vc.tex depend on that. Considering this a cheap operation, you will be able to generate vc.tex anew every time you run pdf latex. Only, in this case, every move you make will recompile the source because the initial file vc.tex has changed. If you want to avoid this complication, then you should leave out vc.tex from dependencies for $(latexfile).pdf. So, when you commit, which changes the revision number and not source files, the process will not lead to an automatic recompile. In this case, the LaTeX document will only show newly revised information, whenever it’s edited after that revision.

LaTeX is a document preparation software for high-quality typesetting. It is commonly used for medium to large technical or scientific documents and can be used for any form of publishing. You need to keep in mind that LaTeX is not a word processing software and it won’t help you with the appearance. LaTeX focuses more on the right content and enables you to deliver accurate information. This software is based on the idea that document design is to be left to document designers, while authors should pay attention to writing and delivering high-quality content.

Melissa Kwan

Click Here to Leave a Comment Below

Leave a Comment: