Add a version number to the title of a LaTeX docum

2019-03-15 05:04发布

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:

Title

Me

4/13/2010

v1.2

8条回答
beautiful°
2楼-- · 2019-03-15 05:23

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.

查看更多
【Aperson】
3楼-- · 2019-03-15 05:27

If you need to display the version number only in the titlepage, you just need to modify it using

    \begin{titlepage}
    ...
    Version 1.x
    ...
    \end{titlepage}

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:

\def\Version#1{\def\version{#1}}

so that you define the version number with \Version{} and recall it with \version.

查看更多
登录 后发表回答