cd /home/rc; xdg-open "index.html"

Latex Setup

19/08/20 :: st_mtime:16/05/2021

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:

FROM ubuntu:groovy
LABEL maintainer=""

RUN ln -snf /usr/share/zoneinfo/Europe/Rome /etc/localtime && echo $TZ > /etc/timezone

RUN  apt update \
    && apt install -qy texlive texlive-xetex latexmk \
    && apt install -qy python3 python3-pygments curl git  
FROM ubuntu:latest

LABEL maintainer=""

RUN ln -snf /usr/share/zoneinfo/Europe/Rome /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
    && apt-get install -qy texlive-full \
    && apt-get install -qy python3 python3-pip \
    && pip3 install pygments 
FROM ubuntu:latest

LABEL maintainer=""

RUN apt update && apt install -qy curl libgetopt-long-descriptive-perl libfontconfig git

COPY texlive.profile /
ENV PATH=/usr/local/texlive/2020/bin/x86_64-linux:$PATH
RUN curl -O
RUN tar -xzf install-tl-unx.tar.gz 
RUN mv install-tl-20* install-tl
RUN cd install-tl && perl install-tl -profile /texlive.profile
RUN tlmgr install xetex latexmk

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
        - git checkout master
        - curl -LOk
        - curl -O    
        - ./
        - latexmk -xelatex --shell-escape <file>.tex
        - <file>.pdf 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 +LaTex Workshop with this config :

    "": [
        "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.