Enhancing Your Beamer Presentations with SVG Figures and Inkscape Layers

If like me you’re using Beamer to create slides in LaTeX, there’s a neat trick that helps you include SVG vector graphics—and even better, animate them progressively using Inkscape layers and Beamer’s overlay features like \pause or \onslide.

Why SVG and Inkscape?

SVG (Scalable Vector Graphics) is a great format for high-quality images that scale well without losing resolution. If you create your SVGs using Inkscape, you can organize your graphic into layers. These layers can then be revealed step-by-step in your presentation using Beamer’s overlay commands. This avoids the hassle of creating multiple image files or slides to simulate animation, and it keeps everything clean and well aligned on all slides displaying your image.

SVG image inclusion in LaTeX

To include SVGs in LaTeX and make use of LaTeX commands inside the image (like math formulas or labels), you can use the svg package. This package allows you to embed SVG files and even interpret LaTeX code within them during compilation.

Here’s a typical command to include an SVG:

\usepackage{svg}
...
\includesvg[inkscapelatex=true, width=\textwidth]{<image.svg>}

It’s thus very similar to the command \includegraphics of the package graphicx (see here). For more information, you can have a look to the full description of the SVG package on CTAN (check there the full documentation in pdf).

Step-by-Step Animation with Layers

In Inkscape, you can create multiple layers and insert LaTeX overlay commands like \pause or \onslide directly into the layer content. When compiled with Beamer, these layers will appear progressively, creating a smooth animation effect.

There’s for instance this video tutorial showing how to set up layers in Inkscape for this purpose.

What You Need

To make this work, you’ll need:

  • Inkscape installed on your system (check here for installation instruction)
  • LaTeX compilation with the -shell-escape option enabled (this allows LaTeX to call Inkscape during compilation). For instance, if you use pdflatex the command to run is
        pdflatex  -shell-escape <latexfilename>
    

Remark: The -shell-escape option should be used with caution in general as this gives the possibility to latex compilation to execute shell commands.

Real-World Use

I use this technique regularly in my course and seminar slides. It’s a great way to present complex diagrams step-by-step without cluttering your slides or manually managing multiple image versions.

Here is a minimal example as well as this minimal SVG file you can use (note that if you visualize it in your browser by clicking on the link, you’ll see all the layers at once, as well as the \pause command). Note that this example must be compiled with the command pdflatex -shell-escape MiniEx.tex in a directory including the SVG file test.svg. All the sources of this example are included in this zip file. The produced minimal PDF presentation is available here.

%% File: MiniEx.tex
\documentclass{beamer}

\title{Minimal Beamer Example with Inscape Overlays}
\usepackage{graphicx}
\usepackage{svg}
\begin{document}

\frame{\titlepage}

\begin{frame}
\begin{center}
\includesvg[inkscapelatex=true,width=.4\textwidth]{test.svg}
\end{center}
\end{frame}

\end{document}
Laurent Jacques
Laurent Jacques
FNRS Senior Research Associate and Professor