Using Pandoc for My Slides: 2023 Update

Look at the colours!

Posted: 2023-01-27
Updated: 2024-04-13
Stats: 910 words / ~5 minutes

In March 2021 I wrote about using pandoc to make my presentations for class. Towards the end of that post, I wrote:

My next quest will be to figure out how to make my own themes and styles. If you know how or have a nice, simple, guide, let me know.

Well, it turns out that I was not far from a simple solution. With the recent release of pandoc 3.0 I was reminded that pandoc is, quite certainly, my most-used-tool for teaching — I use it for my slides, and all the different documents that I need to make at my various teaching positions.

Adding some colour

Being quite content with the built-in options for themes (colortheme, innertheme and outertheme) I was under no pressure to seek out a solution. That is, until it became necessary to my sanity to be able to open a presentation and immediately recognize what school it was for — I teach at four different places!

The answer was in the Beamer user Guide and involves making a small .tex file.

Here is a (slightly modified) version that I use for one of my schools:

% define some new colours
% NB RGB and rgb are not the same thing!


% tell LaTeX to use one of those colours for the structure


% tell LaTeX which colours to use for which elements

\setbeamercolor{background canvas}{bg=lessdarkbackground}
\setbeamercolor{block title}{bg=darkbackground, fg=sorange}
\setbeamercolor{block body}{bg=darkbackground, fg=white}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{itemize item}{fg=sorange}
\setbeamercolor{itemize subitem}{fg=sorange}
\setbeamercolor{itemize subsubitem}{fg=sorange}
\setbeamercolor{enumerate item}{fg=sorange}
\setbeamercolor{enumerate subitem}{fg=sorange}
\setbeamercolor{enumerate subsubitem}{fg=sorange}
\setbeamercolor{section number projected}{fg=white, bg=sorange}

% some extra commands


These LaTeX instructions override the default blue theme, whale, and add a few extra functions that I rarely use, but don’t want to bother looking up again.

Running pandoc with the appropriate commands gives me this:

set of 6 slides using modified colour scheme made with pandoc
Open the image to see the gory details

Personally, this is not my favourite colour scheme. It does match what is used at the school, however, and that is what I was going for.

Why the quote?

I included a slide with a quote to point out that some solutions are more obvious than others. I am not at all comfortable with LaTeX, maybe someday. For now, I have the tools I need, and time-wise I can manage. I believe that learning LaTeX would be a logical step for someone in my position: many academics use LaTeX — I am just a professor, and do not need to publish, but knowing this skill would be an advantage.

Moving on to the quote.

I like to keep things simple. A quote, with italic or emphasized text, followed by the name of the person quoted, flushed right, boldfaced, preceded by “—.”

See? Simple.

At one point, I had some trouble getting the author’s name to the right of the slide. Then, I had trouble getting the text to be bold without resorting to LaTeX commands like \textbf.

As is usually the case, the problem was how I was positioning the Markdown markup.

This was wrong:

\hfill **--- Kim Stanley Robinson** \
\hfill *The Ministry for the Future* (2021)

Why? Because of how pandoc interprets the * following the \hfill (horizontal fill) command. It just doesn’t work like that.

This is the simple solution:

**\hfill --- Kim Stanley Robinson** \
*\hfill The Ministry for the Future* (2021)

Wrapping the \hfill command in the markup takes care of the problem. No more resorting to LaTeX commands.

Workflow 2023

Nothing much has changed since before in terms of workflow.

Generally, I keep a “build” folder for each of my employers. Things have become disorganized since deciding on this structure, and I need to revamp it. But, right now, it might look like this:

    └── build
        ├── assets
        │   └── logo.png
        └── style.tex

I would prepare my Markdown file with the appropriate front matter and run:

pandoc -t beamer --pdf-engine=xelatex -H style.tex -o output.pdf

(-t beamer is the output type, --pdf-engine=xelatex because I like to use different fonts, -H style.tex includes my “theme” in the header)

Doing that is not what I call a fluid workflow. And I have seen many, many solutions. My “solution” is to use Kate.

Kate has an “External Tools” plugin. With that, it is possible to create a button, or menu item, to do the work for you.

Kate screenshot, external tools config
Several little tools, like spellchecking with LanguageTool

Kate screenshot, pandoc convert to beamer example
Under the hood

So, now I have a single-click “build” button for Markdown files. That means I can “preview” my slides when I want by leaving zathura open. I also tend to spellcheck things frequently.

Once I have the PDF file, I manually copy it into my shared Syncthing folder, so the file is on my phone. Then, when I turn on my work computer, the file will be synced to it as well.

Ready to teach.

The Next Step

Learning how to make a bloody Makefile!

I don’t need it (yet), but it would be nice to know how to do this. It would streamline things, for certain.

pandoc has a website and a GitHub. It can be installed on different operating systems.

I highly recommend you follow the pandoc account on Mastodon as well as; those accounts are overflowing with tips like this trick to prevent pandoc from adding title, date or author to the document text or how to create example and alert blocks in Beamer.

You can or contact me if you wish to comment or propose a correction.