DEV Community

Cover image for Installing LaTeX themes on your machine/Emacs org-mode
Laura Viglioni
Laura Viglioni

Posted on • Updated on

Installing LaTeX themes on your machine/Emacs org-mode

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:


Most of these presentations are created with beamer and its default themes, although beamer is very handy, these themes are a little bit old-fashioned. We can use modern custom themes like metropolis:

My org-mode code

I use org-mode 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:

#+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
*** 

Enter fullscreen mode Exit fullscreen mode

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:

% 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}
Enter fullscreen mode Exit fullscreen mode

woa... a little bit verbose compared to org, huh 👀

But the most important lines for this text are:

#+beamer_theme: Copenhagen
Enter fullscreen mode Exit fullscreen mode

or
aren't you convinced to use org at this point? 😨

\usetheme{Copenhagen}
Enter fullscreen mode Exit fullscreen mode

If we want to use custom themes, as we can read on metropolis documentation, 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 kpsewhichif you are a mac user, it comes in MacTex package :)

$ kpsewhich -var-value=TEXMFHOME
Enter fullscreen mode Exit fullscreen mode

In my case it returns:

/Users/laura.viglioni/spacemacs/Library/texmf
Enter fullscreen mode Exit fullscreen mode

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

PS.: If you want to know more about org-mode, checkout these videos:

Top comments (0)