<< Go back to Posts

Storing (Custom) Latex Theme

When using pandoc + beamer, I often store my theme file in the same folder. However, when you have ten slide decks, you end up with ten copies of the theme. Here, I describe where you should store these custom themes.



Introduction

The default Beamer themes are awful.

I usually use the metropolis template1, but sometimes I want to change and try new styles.

Because this is easier to setup, I use pandoc. The only difficulty with this tool is to combine information you found about Latex and Beamer …

Beamer Theme

A beamer theme is a .sty file which has a name like:

  • beamertheme<PACKAGENAME>.sty
  • beamercolortheme<PACKAGENAME>.sty
  • beamerfonttheme<PACKAGENAME>.sty
  • beamerinnertheme<PACKAGENAME>.sty
  • beameroutertheme<PACKAGENAME>.sty

If you want these files, you can search them here 2.

When you want to use the TOTO theme, you should include in the pandoc yaml header something like:

---
  title: my title
  date: today ?
  header-includes:
  - \usetheme{TOTO}
---

As you can see, there are 5 different theme files. For each, you have a command to call it:

Name Role Command
beamerthemeToto.sty main theme \usetheme{Toto}
beamercolorthemeToto.sty color theme \usecolortheme{Toto}
beamerinnerthemeToto.sty inner theme \useinnertheme{Toto}
beamerouterthemeToto.sty outer theme \useoutertheme{Toto}
beamerfontthemeToto.sty font theme \usefonttheme{Toto}

If you are building your own theme, you do not necessarily need these 5 different files. You can only create a single beamerthemeTiti.sty with all in it.

The 5 files allow to conceptually separate elements, to distinguish colors behavior from font from other stuff. Look at the Beamer Cheat Sheet 3 to understand what should be in each file.

Global Path

My main concern is the following:

I have 10 slides deck using the same template. Each slide deck has its own repository. Thanks to that, sources (images mainly) are not shared and we can modify one project without impacting the other.

The main problem is that I end up with \(10 \times 5\) template files, \(5\) in each repository. Because these files are duplicates, I do not want to add them to the git tracking system. However, I still want to know which .sty in case of. git status talks a lot, and it is difficult to find out what needs to be added.

My question was “where do I put these .sty files so I can access them anywhere in my computer without the need for copy/paste”.

Solution

  1. I created the ~/.pandoc/ folder.
  2. I updated my .bashrc file with export TEXINPUTS="$TEXINPUTS:$HOME/.pandoc/" 4
  3. I added all my template file in the ~/.pandoc/ folder, leading to:
~/.pandoc/
  beamerthemeTOTO.sty
  beamerthemeTITI.sty
  beamerthememetropolis.sty
  beamercolorthememetropolis.sty
  ...

This solved my problem.

Sources



>> You can subscribe to my mailing list here for a monthly update. <<