« /home/rc

latex setup


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.

  stage: build
  image: registry.gitlab.com/rcastellotti/latex
    - 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
      - <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.

  stage: deploy
    - mkdir public
    - cp <file>.pdf public
      - 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": [
  "[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:

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.