Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A Cookbook for LaTeX with git
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexander Povel
A Cookbook for LaTeX with git
Commits
ed946b88
Commit
ed946b88
authored
Oct 29, 2020
by
Alexander Povel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust README
parent
9e4a81d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
README.md
README.md
+13
-14
No files found.
README.md
View file @
ed946b88
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment