How to Create Beautiful Beamer Slides with Emacs

With Emacs and Beamer, you don't need Powerpoint anymore.

Org Beamer 00 Featured Image

Emacs is a highly versatile program. Aside from being a text editor, it can be your email client, news reader and even your finances tracker. This is because you can easily adapt Emacs to any purpose and situation.

Beamer is a LaTeX module that allows you to create presentation slides in a similar manner to creating LaTeX documents. Here we will show you how to use it to create presentations inside Emacs.

How does Beamer work?

Beamer is an extension of the LaTeX document system that allows you to create a customizable slides module.

Org Beamer 02 Beamer Website

One key difference between Beamer and the default LaTeX is that it uses frames instead of sections. A Beamer frame is a document page that you can change the content and its geometry. For example, it is easy for Beamer to use an entirely different theme between multiple frames.

Org Beamer 03 Sample Slide Emacs

This approach allows Beamer to be both flexible and portable.

Using Beamer in Emacs

One of the easiest ways to use Beamer in Emacs is through Org Mode. With that, installing Org Mode and LaTeX is incredibly easy. First, you need to install LaTeX through your distribution’s package repository.

In Ubuntu, run the following command to install LaTeX:

sudo apt install texlive-full

From there, Ubuntu will then download and install all the necessary packages to properly run the whole LaTeX suite in your computer.

To install Org Mode in Emacs, press Alt + X, then type “package-install”. This will then bring up a prompt where you can type the package that you want to install. Type org.

Org Beamer 05 Install Package Emacs

Doing that will then tell Emacs to download, compile then install the source code for Org to your Emacs installation.

Org Beamer 06 Org Installed In Emacs

Creating a Basic Presentation in Emacs

With LaTeX and Org mode installed, you can now create your first Beamer document.

  1. Press Ctrl + X, then Ctrl + F to open Emacs’ File Buffer prompt. From there, provide a file name for the document that you want to make.
Org Beamer 07 Emacs File Buffer Menu
  1. Next, press Ctrl + C, Ctrl + E, then #. This will insert the default Org template to start your new document.
Org Beamer 08 Select Template Emacs
  1. When Org asks you for the type of template you want to use, type “default” to insert the default template in your document.
Org Beamer 09 Default Template Emacs

This template contains the recommended defaults for any Org document. For the most part, this template will be enough for a basic presentation.

Org Beamer 10 Insert Template Emacs
  1. The next thing to do is to tell Org that you want to create a Beamer presentation. In order to do that, you need to add the following line at the end of your template:
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
Org Beamer 11 Add Beamer Support

With that done, you can now start creating your first slide. Org uses the first two levels of the document to establish both the category and section of your presentation. Knowing that, consider the following example:

* Introduction
** First Topic
*** The Introduction to the First Topic
	Welcome to the first topic, this is the first slide
	of the first topic.
  • The first level serves as the category and title slide for the all the slides under it. This allows you to group the slides underneath it according to a particular theme. In this example, I labelled the first level as “Introduction”.
  • The second level serves as a sub-category which you can use to further specify your slides. This is similar to the \section{} block on a regular LaTeX document.
  • Lastly, the third level are the slides that will be displayed in the final Beamer output. This means that any content you write under this level will be displayed as text in your presentation.
Org Beamer 12 Sample Beamer Document
  1. To export your slide as a Beamer presentation, press Ctrl + C, then Ctrl + E. This will bring up Org’s Export Menu. Press Shift + O to compile and open your presentation.

Adding Bullets and Symbols to Slides

Aside from creating simple text slides, it is also possible to include bullet points and special symbols in your Beamer presentation.

Org Beamer 13 Sample Slide With Symbols

To add bullets in a Beamer slide, all you need to do is to create an Org bullet under a slide heading. Org will detect and convert it to its Beamer counterpart. For example, this is an excerpt for a Beamer slide with three bullet points:

* Introduction
** First Topic
*** The First Topic in Bullets
	- Hello! This is the first bullet.
	- Hi there, this is the second bullet.
	- Lastly, this is the third bullet.
Org Beamer 14 Beamer Slide With Bullets

On the other hand, using special symbols in Beamer can be tricky. This is because you will need to provide their specific LaTeX control character. For example, to write the Greek symbol “α” you will need to write the code \alpha in your Org document.

One way to deal with this issue is through Org Tab Completion. This is a built-in feature that provides helpful suggestions for the special characters that you can insert. To use this, all you need to do is to begin typing the name of a character and press Esc + Tab.

Org Beamer 15 Emacs Completion Suggestions

Adding Images to Slides in Emacs

Beamer also has native image support. All you need to do is to provide the file path of the image in double square brackets.

Org Beamer 16 Emacs Org Links

The file path for these links can either be absolute or relative. For example, the following code creates two Beamer slides that displays two different images:

* Introduction
** First Topic
*** The First Image of the Topic
	- Hello! This is the first image with an absolute link.
	[[/home/ramces/tmp/org/presentation/img1.jpg]]
*** The Second Image of the Topic
	- Hello again! This is the second image with a relative link.
	[[./img2.jpg]]
Org Beamer 17 Sample Slide With Image

Adding Tables to Slides in Emacs

Aside from symbols and images, you can also insert tables in your presentation. Beamer uses the default LaTeX table syntax for the table’s content which it then converts to a printable line table.

Org Beamer 18 Tex Code With Table

One issue with this approach is that the LaTeX table syntax can get incredibly complex. LaTeX allows you to change the very nature of how you create and format line tables. While this can be useful for advanced users, it can be an issue for beginners.

Org Mode allows you to circumvent this requirement and create presentation-ready tables through its own table function. Further, creating an Org-style table is also incredibly easy. All you need to do is to type the pipe symbol (|) and press Tab.

Org Beamer 19 Slide With Org Table Emacs 1

This will then automatically generate a single-column table where you can type the data that you want to present. From there, you can extend the columns and rows that you can use by typing beyond the current table and pressing Tab.

Org will also readjust the table’s size to fit the new content. For example, this is a slide that has three columns:

*** The First Table of This Topic
	- Hello again! This is a slide with three columns
	      | This is | the first  | row |
          |---------+------------+-----|
          | This is | the second | row |
          | This is | the third  | row |
          |---------+------------+-----|
          |         |            |     |

Once done, you can now convert this slide by going through Org’s Export Menu. From there, Org will then convert each table cell to its respective Beamer equivalent.

Org Beamer 20 Tex Org Comparison Emacs

Changing the Default Beamer Theme in Emacs

By default, Beamer uses the “default” theme in all its slides. It is a generic blue-white theme that follows LaTeX’s design cues. While this will work for almost any type of presentation, some users might find this theme too formal and technical.

Org Beamer 21 Default Beamer Theme

To change the default theme in Beamer, add the #+LaTeX_HEADER: variable at the start of your document. Follow that with the name of the theme that you want to use. For example, this is a Beamer document that uses the Berlin theme:

#+title: sample-beamer
#+author: Ramces Red
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
#+LaTeX_HEADER: \mode<beamer>{\usetheme{Berlin}}
 
* Introduction
** The First Topic
*** The First Topic of This Topic
	- Hello! This is the first slide of the first topic. I am using the Berlin theme here!
Org Beamer 22 Berlin Beamer Theme

Frequently Asked Questions

Is it possible to use the section headings as markers for different slides?

Yes! It is entirely possible to use both the first and second-level headings as markers for slides. This can be helpful when you only need to create a few slides and you don’t need any additional subheadings for your presentation.

To change this behavior, all you need to do is to go to your document’s preamble and look for #+OPTIONS:. This is a special variable that determines how your Org document will look and behave.

From there, you then need to find the H: parameter in the variable’s value list. This is what controls which headings are converted to slides in Beamer. The corresponding value will dictate the level of heading that Org will use for its slides. In order to use the higher level headings, you need to provide a value of either 1 or 2.

Is it possible to add audio and video files in a Beamer slide?

Sadly, no. Beamer does not support any multimedia files aside from images.

One way to deal with this is by using a third-party LaTeX plugin such as multimedia. To start using it, you need to write the following line at the start of your document’s preamble:

#+LATEX_HEADER: \usepackage{multimedia}

From there, you can then use the following line of code to create a frame with a single video file attached to it:

#+begin_latex
\begin{frame}
\movie[width=\textwidth,height=3cm]{Video Label}
{samplemovie.mp4}
\end{frame}
#+end_latex

Emacs is saying "Invalid Key" whenever I try to export my Org document. Is my installation broken?

No! This is most probably because Emacs does not currently see a proper Beamer installation. This can happen due to a number of things but the common cause is that Beamer is not properly installed in your system. To fix this, all you need to do is to open your machine’s Terminal and type the following command:

sudo tlmgr install beamer

Doing this will force the TeXLive installation to look and check whether Beamer is currently present in the system. From there, it will then either reinstall Beamer or get a new copy from the internet. Once done, you then need to reload Emacs to see if it now detects the Beamer installation.

Image credit: Unsplash

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox