Add a version number to the title of a LaTeX document

前端 未结 8 1405
攒了一身酷
攒了一身酷 2021-02-04 07:17

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.

\         


        
8条回答
  •  深忆病人
    2021-02-04 07:38

    To provide a \version command like \author, you'd do:

    \let\theversion=\relax
    \providecommand{\version}[1]{\renewcommand{\theversion}{#1}}
    

    If you're not using a titlepage environment, you can redefine \maketitle itself. Look in article.cls (or whatever class file you're using), copy-and-paste, and insert \theversion whereever and however you want. If you want to check for a version number before putting in the title, do something like:

    \def\maketitle{%
    % ... stuff copied from original class file...
    \ifx\theversion\relax
    % do nothing if there is no version defined
    \else\bfseries\theversion% set the version
    \fi
    

    If you don't need it in the title per se you could add it as a footnote to the date (both of those properties related to the freshness of the resource so it makes some sense to put them together.

    \title{My article}
    \version{v1.2}
    \date{\today\thanks{\theversion}}
    

提交回复
热议问题