Installing LaTeX themes on your machine/Emacs org-mode
Tags: latex, emacs, orgmode, beamer
Published: 2021-01-21 01:18:44

For those who need to write academic presentations, it is very common to make use of LaTeX. If you majored computer science you have probably seen a lecture like this:

<img width="60%" style="width:60%" src="https://dev-to-uploads.s3.amazonaws.com/i/cdszcwif1couvql0c3w4.png">
<img width="60%" style="width:60%"  src="https://dev-to-uploads.s3.amazonaws.com/i/its6k79h8ggv6ai7usw9.png">

Most of these presentations are created with [beamer](https://ctan.org/pkg/beamer?lang=en) and its [default themes](https://deic-web.uab.cat/~iblanes/beamer_gallery/index_by_theme.html), although beamer is very handy, these themes are a little bit old-fashioned. We can use modern custom themes like [metropolis](https://github.com/matze/mtheme):

<img width="60%" style="width:60%"  src="https://dev-to-uploads.s3.amazonaws.com/i/xya3tlh5mdcg2hncn3e7.png">

# My org-mode code

I use [org-mode](https://orgmode.org/) to do most of my writing, that includes presentations, articles, personal notes etc. `Org-mode` can interpret LaTeX (and code blocks of a wide range of languages), but talking about `org-mode` is not the point of this text... (_or is it?_ 👀)

The presentation example above was created with the following code:

```org
#+options: H:3 email:nil tex:t toc:t
#+title: Any Computer Science Class
#+date: \today
#+author: Laura Viglioni
#+language: en
#+creator: Emacs 27.1 (Org mode 9.4)
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
#+beamer_theme: Copenhagen


* Graph theory
** Nodes and vertices
*** 
** BFS 
*** 
** DFS
*** 
* Algorithm Complexity
** Big O notation
*** 

```

Compiling that (`M-x org-beamer-export-to-pdf` or `C-c C-e l P`) will generate the first pdf shown in this text. `Org-mode` convert this to a LaTeX file and compiles it, in this example it the `.tex` generated is:

```latex
% Created 2021-01-20 Wed 21:22
% Intended LaTeX compiler: pdflatex
\documentclass[bigger]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usetheme{Copenhagen}
\author{Laura Viglioni}
\date{\today}
\title{Any Computer Science Class}
\hypersetup{
 pdfauthor={Laura Viglioni},
 pdftitle={Any Computer Science Class},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 27.1 (Org mode 9.4)}, 
 pdflang={Portuguese}}
\begin{document}

\maketitle
\begin{frame}{Outline}
\tableofcontents
\end{frame}

\section{Graph theory}
\label{sec:org391ab7d}

\subsection{Nodes and vertices}
\label{sec:org334895a}

\begin{frame}[label={sec:org5882936}]{}
\end{frame}

\subsection{BFS}
\label{sec:orge68a1c6}

\begin{frame}[label={sec:orgba23b2e}]{}
\end{frame}

\subsection{DFS}
\label{sec:orgc3fd777}

\begin{frame}[label={sec:orgf5f342e}]{}
\end{frame}

\section{Algorithm Complexity}
\label{sec:org5501e0f}

\subsection{Big O notation}
\label{sec:orgbe99555}

\begin{frame}[label={sec:orgb18e2bf}]{}
\end{frame}
\end{document}
```
<sub><sup> *woa... a little bit verbose compared to org, huh* 👀</sup></sub>

But the most important lines for this text are:

```org
#+beamer_theme: Copenhagen
```
or 
<sub><sup> *aren't you convinced to use org at this point?* 😨</sup></sub>
```latex
\usetheme{Copenhagen}
```

If we want to use custom themes, as we can read on [metropolis documentation](https://github.com/matze/mtheme/blob/master/README.md), we must compile the project and put the `.sty` files in the same directory as our `.tex` or `.org` that is calling the theme and change it from `Copenhagen` to `metropolis`.

But how to install themes on your system and use them without copying and pasting the `.sty` files every time?

# Installing LaTeX themes to your machine/Emacs

First, you need to know where your system (or Emacs) looks for LaTeX files, including the styles (`.sty`) ones. The easiest way I know is using the command [kpsewhich](https://linux.die.net/man/1/kpsewhich) － _if you are a mac user, it comes in MacTex package :)_

```shell
$ kpsewhich -var-value=TEXMFHOME
``` 
In my case it returns:

```shell
/Users/laura.viglioni/spacemacs/Library/texmf
```

So you must create this dir, if it doesn't exist, and paste the `.sty` files in there and that's it, as simple as that :)


I hope this might be useful to you :)

Be safe, use masks and use Emacs
Xoxo

<img width=70%" style="width:70%"  src="https://media.giphy.com/media/7yojoQtevjOCI/giphy.gif">

PS.: If you want to know more about `org-mode`, checkout these videos:
- [Org Mode Basics In Doom Emacs](https://www.youtube.com/watch?v=34zODp_lhqg&t=1153s)
- [Boost Productivity With Emacs, Org Mode and Org Agenda](https://www.youtube.com/watch?v=Ea_-TaEGa7Y&ab_channel=DistroTube)