| 1 |
%!TEX options = --shell-escape |
| 2 |
% |
| 3 |
% This command causes LatexTools for SublimeText to compile in shell escape mode. |
| 4 |
% |
| 5 |
% If you're not using LatexTools to compile, you will need to enable shell |
| 6 |
% escape on your editor some other way |
| 7 |
|
| 8 |
\documentclass[a4paper]{ltxdoc} |
| 9 |
|
| 10 |
\usepackage{fancyhdr} |
| 11 |
\pagestyle{fancy} |
| 12 |
|
| 13 |
\usepackage{gitver} |
| 14 |
|
| 15 |
|
| 16 |
\begin{document} |
| 17 |
|
| 18 |
\title{\textsf{gitver} -- Git version tags \\ |
| 19 |
for \LaTeX{} projects} |
| 20 |
\author{Charles Baynham} |
| 21 |
\date{2022/07/16 (v\,1.4)} |
| 22 |
\MaintainedBy{% |
| 23 |
This file is maintained by Charles Baynham.\\% |
| 24 |
Bug reports can be opened at\\% |
| 25 |
\url{https://github.com/charlesbaynham/gitver}. |
| 26 |
} |
| 27 |
|
| 28 |
\maketitle |
| 29 |
|
| 30 |
\section{Introduction} |
| 31 |
|
| 32 |
The \textsf{gitver} package gets a description of the current git version of this |
| 33 |
document and stores it in a command |\gitVer|. If memoir or fancyhdr are in use, it |
| 34 |
will also add this to the document footers unless the option |noheader| is |
| 35 |
passed. |
| 36 |
|
| 37 |
It also defines a command |\versionBox| which outputs a box containing the |
| 38 |
version and date of compilation. |
| 39 |
|
| 40 |
For this to work, you must have git installed and available on the command |
| 41 |
line, this document must be part of a git repository, and latex must be |
| 42 |
running in ``shell escape'' mode. This can be enabled by passing \textsf{--shell-escape} |
| 43 |
on the command line when compiling your document, or will be available in the |
| 44 |
options of whatever GUI you're using (try Googling). |
| 45 |
|
| 46 |
Note that online Latex editors like Overleaf.com often do not have git installed. |
| 47 |
Gitver will detect these by the precense of the environmental variable "CLSI" |
| 48 |
and will display the version as "CLSI" instead. |
| 49 |
|
| 50 |
Note that it's a good idea to tell git to ignore all the latex auxilary files, |
| 51 |
otherwise your version will always be ``dirty''. Try the \textsf{.gitignore} file from |
| 52 |
\url{https://www.gitignore.io/api/latex} if you don't already have |
| 53 |
one. |
| 54 |
|
| 55 |
The package is released ``as is'' with no warranty under the LaTeX Project Public |
| 56 |
License, version 1.3. |
| 57 |
|
| 58 |
\section{Usage} |
| 59 |
|
| 60 |
\subsection{Macros} % (fold) |
| 61 |
\label{sub:macros} |
| 62 |
|
| 63 |
% subsection macros (end) |
| 64 |
|
| 65 |
\DescribeMacro{\gitVer} |
| 66 |
% |
| 67 |
The main point of this package, the command |\gitVer| prints a string of text |
| 68 |
describing the current revision of this git repository. Use like so: |
| 69 |
\begin{quote} |
| 70 |
The current version of this repository is ``|\gitVer{}|''. |
| 71 |
\end{quote} |
| 72 |
which compiles to |
| 73 |
\begin{quote} |
| 74 |
The current version of this repository is ``\gitVer{}''. |
| 75 |
\end{quote} |
| 76 |
|
| 77 |
\DescribeMacro{\versionBox} |
| 78 |
Alternatively, you can use a |\versionBox|, most commonly in the footer: |
| 79 |
\begin{quote} |
| 80 |
|\versionBox{}| |
| 81 |
\end{quote} |
| 82 |
% |
| 83 |
gives the output: |
| 84 |
\vspace{3mm} |
| 85 |
|
| 86 |
\versionBox{} |
| 87 |
|
| 88 |
\subsection{Footers} % (fold) |
| 89 |
\label{sub:footers} |
| 90 |
|
| 91 |
By default, \textsf{gitver} will try to place a |\versionBox| into the footer of |
| 92 |
your document. If you're using the |memoir| class or the |fancyhdr| package, |
| 93 |
this will happen automatically. This document has these footers enabled: have a |
| 94 |
look at the bottom of this page for an example. |
| 95 |
|
| 96 |
\DescribeMacro{noheader} |
| 97 |
You can disable the headers by adding the option |noheader| to the package call. |
| 98 |
|
| 99 |
If you include |gitver| without either of |memoir| or |fancyhdr| loaded, it will |
| 100 |
complain. To suppress this complaint, pass the |noheader| option. |
| 101 |
|
| 102 |
To customise the header / footer behavior, pass |noheader| and then use a |
| 103 |
combination of |\versionBox| and |\gitVer| to make your own headers/footers. |
| 104 |
|
| 105 |
% subsection footers (end) |
| 106 |
|
| 107 |
\subsection{Metadata} % (fold) |
| 108 |
\label{sub:metadata} |
| 109 |
|
| 110 |
\DescribeMacro{nopdfinfo} By default, this package also adds the git tag to the |
| 111 |
pdf document's metadata under the subject field. To disable this behaviour, pass |
| 112 |
the option |nopdfinfo|. |
| 113 |
|
| 114 |
% subsection metadata (end) |
| 115 |
|
| 116 |
\section{History} |
| 117 |
|
| 118 |
\begin{itemize} |
| 119 |
\item v1.0 - First release |
| 120 |
\item v1.1 - Remove extra space from output |
| 121 |
\item v1.2 - Use datetime2 instead of datetime to reduce dependancy burden |
| 122 |
and display dates in ISO format |
| 123 |
\item v1.3 - Support LuaLatex |
| 124 |
\item v1.4 - Detect running in online builders via "CLSI" environmental variable |
| 125 |
\end{itemize} |
| 126 |
|
| 127 |
\end{document} |