Skip to content
/ thesis-template Public template

A template for writing your thesis with LaTeX in VS Code

License

Notifications You must be signed in to change notification settings

rosvik/thesis-template

Repository files navigation

Thesis

Build LaTeX document

PDF download

Latest version: Download

Older versions can be found under Releases.

GitHub setup

To make your own thesis repo, create one by clicking "Use this template" -> "Create a new repository" above, and give it a fitting name. Clone it to your machine, and continue to set up LaTeX and a local writing environment in VS Code with the instructions below.

To make the GitHub actions build system work, you need to give write access to your repo. Do this by going to "Settings" -> "Actions" -> "General", and enable "Read and write permissions" under "Workflow permissions". After pushing changes or manually running the action, you should see a pre-release show up under "Releases".

Local environment setup

Installing LaTeX locally isn't the most straight forward thing in the world, but this will hopefully guide you trough most of it. This is the recipie for macOS only, so you will probably need to adjust a bit if you're on another OS.

We'll look at setting up TeX Live, a bunch of packages, latexindent and finally some configuration of VS Code.

Setting up TeX Live

Using TeX Live/tlmgr (TeX Live package manager) and ctan.org to install packages.

Installing tlmgr with a basic set of default packages (~300MB):

  1. Download installer from https://tug.org/texlive/acquire-netinstall.html
  2. Run install-tl
  3. Enter command S - set installation scheme
  4. d - basic scheme
  5. R - return to main menu
  6. I - start installation to hard disk

After installation, look at the installation output, and add the mentioned paths to your PATH, MANPATH and INFOPATH environment variables. E.g. using zsh, add this to ~/.zshrc:

export PATH="/usr/local/texlive/2022/bin/universal-darwin:$PATH"
export MANPATH="/usr/local/texlive/2022/texmf-dist/doc/man:$MANPATH"
export INFOPATH="/usr/local/texlive/2022/texmf-dist/doc/info:$INFOPATH"

After a restart of your terminal, the tlmgr command should be available.

Finally, set the package repository, and check for updates to packages (may need sudo):

tlmgr option repository ctan
tlmgr option repository https://mirror.ctan.org/systems/texlive/tlnet
tlmgr update --all

Installing TeX packages

tlmgr install acmart iftex xstring environ totpages trimspaces \
    ncctools comment preprint quoting libertine newtx inconsolata \
    todonotes chktex latexindent breakcites biblatex enumitem pdfpages \
    microtype setspace booktabs upquote pdflscape

Setting up latexindent

To enable automatic indentation trough latexindent work, you may need to install the "File::HomeDir" perl package.

sudo perl -MCPAN -e 'install "File::HomeDir"'

VS Code config

My Visual Studio Code configuration for LaTeX and BibTeX is included in .vscode/settings.json. Some prerequisites are:

The rest of my VS Code configurations are available at rosvik/dotfiles -> vscode/settings.json

Generate PDF

A PDF is generated automatically on every save in VS Code, as well as on every push through the build-latex.yml GitHub Action. If you want to generate a PDF manually, run:

bibtex main.aux && pdflatex -synctex=1 -interaction=nonstopmode \
    -file-line-error -recorder -output-directory=. main.tex