Menu

Generate Beamer Slides From Org Mode

LaTeX Logo

Introduction

I have been using pandoc (from John Macfarlane) to generate PowerPoint slides. I have documented this here.

For specific projects, where the presentations had to include mathematical formulas, footnotes and citations, I decided to generate "Beamer" slides from Org mode source documents.

Summary

"Beamer" slides are PDF files, which are generated using the LaTeX system.

Org mode has an out-of-the-box Beamer export module. Hence Emacs and LaTeX is all you need to generate Beamer slides

I have documented below my settings, customisations and observations. You can download the file ./org2beamer.zip to see my test and configuration files.

Prerequisites

I use the "texlive" TeX/LaTeX software. I installed the following Debian packages:

texlive
This is not the full TeX/LaTeX set, but sufficient, except for the next item
texlive-latex-extra
is needed because of wrapfig.sty, which is required by the Org mode exporter (Emacs v28.2 Org mode v9.5.5)
cm-super
makes sure you get decent looking "type 1" fonts included in the output PDF document. By default you get "type 3" bit-mapped fonts which do not look smooth
texlive-lang-german
because I write in german and english
texlive-latex-recommended-doc
to have documentation available locally
inkscape
TeX/LaTeX cannot directly deal with scalable vector graphics (SVG) but it calls inkscape automatically to support SVG

I put in init.el

;;; Beamer export
(require 'ox-beamer)

to have the Beamer export option show in the Org mode exporter front-end.

Manifest

The file org2beamer.zip contains the following files:

README.txt txt version of this web-page
test.org Test Org mode source file
test.pdf Resulting Beamer output PDF slides
test.tex Resulting intermediate LaTeX file
mysetup-bmr-169-ysctn.org Org set-up file when using sections
mysetup-bmr-169-nsctn.org Org set-up file when not using sections
myAddUTF8.tex LaTeX symbol definitions
redetho-logo1.svg Test logo
blind_*.svg Test vector graphics file
blind_*.jpg Test image files
lit.bib Test BibTeX file for citations

The files are provided as is. I do not take any responsibility nor provide any warranty.

Installation

Test Usage to Generate a Beamer-PDF-File

While the C-c C-e standard Org mode exporter is fine for tests and occasional exports, I use a Makefile for more complex projects. That Makefile would typically contain (covers both Windows and Linux):

ifeq ($(OS),Windows_NT)
	EMACSCL=$(MYPROGPATH)/emacs-27.2/bin/emacsclientw.exe
else
	EMACSCL=emacsclient
endif

test.pdf:	test.org $(HOME)/mysetup-bmr-169-ysctn.org
	$(EMACSCL) --eval "(find-file \"test.org\")" \
	 "(org-beamer-export-to-pdf)"

Using Org Mode's SETUPFILE Mechanism for Configuration

The file test.org contains the slide content and essential meta data. It references the file mysetup-bmr-169-ysctn.org using Org mode's #+SETUPFILE: mechanism. mysetup-bmr-169-ysctn.org configures the Org mode Beamer exporter and contains LaTeX and Beamer settings. The key settings are:

Obviously, different key settings require different set-up files, hence the names of the set-up files. I include in the ZIP archive the file mysetup-bmr-169-nsctn.org which is meant for shorter presentations that do not need section divider slides.

Please read below for details about slide format customisation, which are also effected by the set-up file.

Observations

Note that some of the issues discussed below are LaTeX/Beamer issues. However, I discuss them here because I collected solutions for them from various documentation pieces or from the internet.

I also document how these issues can be addressed directly from the Org mode source code or the setup-file which gets included by the Org mode source file.

Tables

So far I did not need to change the table settings from the defaults.

Links

When you want to generate a link in a Beamer presentation to a PDF document from Org mode, you need to provide a description, like so

[[./file.pdf][Description]]

If you omit the description, like

[[./file.pdf]]

the first page of the PDF document gets embedded in the output Beamer PDF file.

Language Support

For non-English language texts, you would add

#+LANGUAGE xx

to your Org mode text, where xx is the ISO language code. The Org mode exporter will replace the AUTO literal in the

\usepackage[shorthands=off,AUTO]{babel}

statement from the set-up file by that language.

However: The table of contents will always read "Outline". This literal seems to come from Beamer.

Support for special characters

The set-up file includes the statement

#+LATEX_HEADER: \input{~/texmf/myAddUTF8}

The file myAddUTF8.tex is included in the ZIP-file. It contains LaTeX definitions for additional UTF-8 characters you could use directly in the Org mode main file. I chose to store myAddUTF8.tex in the texmf sub-directory of my home directory.

Images - Scaling

The file test.org shows how to scale images. I found that scaling relative to the LaTeX textheight works best for slides, both for 16:9 and 4:3 aspect ratios. However, if you use columns, then scaling relative to textwidth is often preferable, as textwidth tracks the column width.

For LaTeX article documents I usually scale relative to textwidth, as article has a portrait aspect ratio.

Images and Text on the same Slide

Putting text and images on the same slide on top of each other is straight forward. Using columns, they can be put next to each other. You could also stack images on top of each other in the same column.

Often Beamer documentation shows how to employ Beamer's »block« environments. Blocks allow to use coloured text and background and additional title text, which might have its own text and background colours.

Scalable Vector Graphics (SVG) Issues

When referencing SVG files to be included in the PDF-slides, inkscape is being run automatically in the background, to help LaTeX/Beamer deal with SVG.

By default text elements (text objects), which are contained in the SVG files, would be processed by LaTeX/Beamer. E.g. an underscore would switch to subscript. Usually, this is not what you want. To prevent this, the set-up file contains the option inkscapelatex=false in the line

#+LATEX_HEADER: \svgsetup{inkscapelatex=false, inkscapearea=page}

By default, the "bounding box" of all graphics elements in the SVG file determines what is being projected/scaled into the resulting LaTeX/PDF. The option inkscapearea=page rather makes shure that the full size of the SVG is considered instead, either using the viewBox attribute or the width and height attributes in the SVG file.

Various Beamer Slide Format Customisations

The set-up file mysetup-bmr-169-ysctn.org contains various customisations, how the generated slides shall look like. The customisations are applied to the default LaTeX/Beamer »theme« (theme is a Beamer term for a defined slide layout). These are my personal preferences:

Covered Functionality

The Org mode built-in exporter to Beamer slides supports the full Org functionality, like macro support and Org babel support.

When using Pandoc instead, you might want to use the ox-pandoc package from Alex Fenton, to be able to use most of Org's functionality and use Pandoc for additional target formats like PowerPoint.

Other

I trust you notice that mysetup-bmr-169-ysctn.org also contains Org mode in-buffer customisations for HTML export and text export. I have written about HTML export here

You might also be interested in LaTeX article generation from Org mode or using pandoc together with Org mode.


Last change: 2025-03-16
© 2002-2025 Dr. Thomas Redelberger redetho(a‍t)gmx.de

Close menu