Commit ed946b88 authored by Alexander Povel's avatar Alexander Povel

Adjust README

parent 9e4a81d9
......@@ -479,7 +479,7 @@ Now, we only need to get the contents of that variable into the LaTeX source,
and finally the compiled PDF.
The LaTeX package `hyperref` can modify PDF metadata.
In the LaTeX preamble, we can then use
In the LaTeX preamble, we can then use, for example,
```latex
\usepackage[pdfusetitle]{hyperref}% pdfusetitle reads from \author and \title
......@@ -495,23 +495,22 @@ Note that in LaTeX, you likely used `\author{<author's name>}` and `\title{<docu
somewhere in the preamble to generate a title page.
`hyperref`'s `pdfusetitle` option will use those values for the PDF metadata.
Lastly, `pdfcreator` will fill the `Application` field we see above.
However, `\GitRefName{}` and `\GitShortSHA{}}` need to be defined.
These are defined earlier in the preamble:
However, `\GitRefName{}` and `\GitShortSHA{}}` need to be defined first.
This happens earlier in the preamble:
```latex
\newcommand*{\GitRefName}{n.a.}
\newcommand*{\GitShortSHA}{n.a.}
\directlua{
dofile("lib/lua/envvar_newcommands.lua")
}
```
(Side note: use the [starred variant of `newcommand`](https://tex.stackexchange.com/a/1057/120853),
unless you need paragraph breaks, which is mostly not the case).
Using the above definition, the fields will just show up as *not available* if for example
compiling locally ("at home").
The server has a script employing `sed` (since we're using GNU/Linux there),
specified in [.gitlab-ci.yml](.gitlab-ci.yml), that seeks `GitRefName` and `GitShortSHA`
and replaces whatever comes in the curly braces of those commands.
See the `script` of the `replace_git_metadata` job in that file.
This runs, with the help of LuaTeX's [Lua](https://www.lua.org/about.html) integration,
some [Lua code](lib/lua/envvar_newcommands.lua) directly in LaTeX.
Within Lua, `os.getenv(<string> name)` lets us retrieve environment variables, which are
then turned into macros/control sequences (`\newcommand`) of a given name using
`token.set_macro(<string> csname, <string> content)`, see the [LuaTeX reference](http://mirrors.ctan.org/systems/doc/luatex/luatex.pdf)
on all the included Lua functionality provided by LuaTeX, on top of regular Lua.
### Add PDF Download Button
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment