Skip to content

Commit

Permalink
Adjust README
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Oct 29, 2020
1 parent 9e4a81d commit ed946b8
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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](https://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

Expand Down

0 comments on commit ed946b8

Please sign in to comment.