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
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
mysetup-bmr-169-nsctn.org Org set-up file when not using sections

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 is 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 add that language to the

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

statement from the set-up file. The desired language gets added after the english babel option in the intermediate .tex file. Hence it will become the "start" language used for the slides.

However: The table of contents will always read "Outline".

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 paperheight works best for slides, both for 16:9 and 4:3 aspect ratios. However, for LaTeX article documents I usually scale relative to paperwidth, as article has portrait aspect ratio.

Images - Multiple on a page

Beamer allows for fine grained control of how to use the slide real estate of individual slides, e.g. when placing multiple images on a slide. However, I have not yet needed that functionality.

Scalable Vector Graphics (SVG) Text 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 line

#+LATEX_HEADER: \svgsetup{inkscapelatex=false}

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 for Beamer slides supports the full org functionality, like macro support and org babel support.

When using Pandoc instead, you might want to try the ox-pandoc package, 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: 2024-06-27
© 2002-2024 Dr. Thomas Redelberger redetho(a‍t)gmx.de

Close menu