The title section of my LaTeX documents usually look like
\title{Title}
\author{Me}
%\date{} %// Today's date will appear when this is commented out.
\begin{document}
\maketitle
I'd really like to add another line in the title section for a version number:
\title{Title}
\author{Me}
\version{v1.2}
%\date{} %// Today's date will appear when this is commented out.
\begin{document}
\maketitle
It doesn't necessarily have to be a command named version
, but how can I get a version number to appear after the date (which is after the author)? I can manually set the version number.
So:
If you have your document controlled inside a git repository, then this can be achieved using the gitinfo package. If correctly configured (which involves adding post-hooks to your git system), you can simply use
\gitVtag
to call the version number (as embodied in a git tag) or e.g.\gitAbbrevHash
to get the abbreviated hash of the current commit of the repo.If you need to display the version number only in the titlepage, you just need to modify it using
after issuing the command \maketitle.
Otherwise, if you need to recall it in several times throughout the document, it's better to define a variable:
so that you define the version number with
\Version{}
and recall it with\version
.