I'm not sure if this is possible, but my goal is to include some information about the current point of my LaTex file in its git source history in the PDF output of my file.

What I want to be able to access is the information the results from the following shell command git describe --tags

So I'd like to write a macro which triggers when pdftex is run. The macro would then run git describe --tags and then the value of that command would be placed in the designated places within the output document (namely the page headers).

I'm really not sure if it's possible to write a LaTeX macro that can run shell commands, but I'd be grateful if anyone has any suggestions.


1 Answer 1


As suggested in the comments, there are the gitinfo packages, which offer a broad range of features. If you are looking for a quick-and-dirty solution instead, you can use Heiko's package catchfile to read the contents of a file into a macro. The syntax "| <cmd>" allows to input the stdout of <cmd> as a file.

% arara: pdflatex: { shell: on }
\CatchFileDef\gitdescribe{"| git describe --tags"}{}

The output of \texttt{git describe --tags} is ``\gitdescribe''.

Before running the TeX file (which I named test.tex), I did

$ git init
$ git add test.tex
$ git commit -m "Some commit"
$ git tag 0.0.1 master

Important: Run pdflatex with the option --shell-escape!

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .