Recently ('bout 2 years tbh) I started writing my uni notes in latex, to make the process a little more 2020-like I decided to use Gitlab CI/CD.
This allows me to have my .tex
file compiled whenever I push to my repo (if you push PDFs in you repo you are an horrible person, if you
use github releases manually it's ok but you're not my bear-friend).
Enough talking, let's get down to business.
Here are three different container images:
Remember that texlive-*
contains tlmgr
so if a package is used only once it can just be installed adding tlmgr install <pkgname>
in .gitlab-ci.yml
Speaking of .gitlab-ci.yml
this is what I usually use.
compile_pdf:
stage: build
image: registry.gitlab.com/rcastellotti/latex
script:
- git checkout master
- curl -LOk https://github.com/JetBrains/JetBrainsMono/raw/master/fonts/ttf/JetBrainsMono-Regular.ttf
- curl -O https://gitlab.com/rcastellotti/latex/-/raw/master/gitinfo.sh
- ./gitinfo.sh
- latexmk -xelatex --shell-escape <file>.tex
artifacts:
paths:
- <file>.pdf
gitinfo.sh
is a script to use gitinfo2 in manual mode, here you can find a raw version easy to curl
.
You can check GitLab Docs to know
where to find your compiled pdf.
Keeeping your repo private might be a good idea, if you want to have pdfs accessible by anyone I highly suggest to deploy your pdf using GitLab Pages adding the following to .gitlab-ci.yml
, make sure Pages are activated and check the visibility in Settings > General > Visibility, project features, permissions.
pages:
stage: deploy
script:
- mkdir public
- cp <file>.pdf public
artifacts:
paths:
- public
On my machine I install texlive-full python3-pygments
and I use VSCode and LaTex Workshop with this config :
{
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-xelatex",
"--shell-escape",
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}
],
"[latex]": {
"editor.rulers": [150],
"editor.wordWrap": "wordWrapColumn",
"editor.wrappingIndent": "same",
"editor.wordWrapColumn": 150
}
}
I also do some spellecking with aspell
, I usually download the Italian dictionary, extract it and run the following:
./configure
make
sudo make install
Now i can spellcheck my file running aspell --lang=it --mode=tex check <file>.tex
You can find a bunch of useful files in this repo (also contains container images), if you need help and have a bunch of bear pics feel free to contact me.