Randy Ridenour

Beamer Presentations with Org Mode

Jun 1, 2020

When we moved all courses online for the semester because of the COVID-19 pandemic, I found myself having to make many more presentation slide-decks than I normally do, especially when I normally don’t do any at all. Keynote produces some beautiful slides, but it requires using the mouse more than I like. I wanted something that I could use to make slides with just a few keystrokes. I settled on exporting an Org mode document to Beamer slides. This is an explanation of the challenges that I had and the solutions that I found.

Beamer πŸ”—

The Beamer class is a tool used to produce presentations with LaTeX. It provides the same advantages for presentations that standard LaTeX provides for other document types, including elegant mathematical formulas, transportability between computing platforms, and the ability focus on content when writing. There are disadvantages, though. Writing LaTeX can be cumbersome, since it is not a simple markup language. After gaining a certain proficiency, it is possible to write it fairly easily. Even so, it is never as simple as using something like Markdown.

Solution πŸ”—

The solution that I found was Org mode, a very powerful system that includes a simple markup language and the ability to export to LaTeX. Producing the slide deck was easy, and there were many great examples online. Producing an article was also easy, again with great examples. Producing both a slide presentation and an article, using the same contents file should have been easy, since the official guide to Beamer explains how to do that in LaTeX. Unfortunately, I couldn’t find much guidance on how to do this with Org Mode. The only article I could find was this on the official Org mode site . It seemed too complicated to me, and I was tempted to just go back to directly writing LaTeX. I decided to try anyway, but I quickly ran into a series of problems:

  1. The Org Beamer export automatically inserted a title slide with \maketitle. Unfortunately, using the same content for the presentation and notes requires using the ignorenonframetext switch in the document class declaration. Since the export didn’t place the command in a frame, there was no title slide.
  2. I attempted to fix this by beginning the contents file with a title-less frame that included the \maketitle command. That generated a title page, but it came after the table of contents slide.
  3. The article export did not treat headings correctly, and failed to recognize the Beamer-specific commands.

This was enough to make me want to scrap the project, especially when I looked at the site linked above. The author fixed the title issue by hacking the Beamer export file, something that I certainly didn’t want to do. So, as is often the case, after hours of searching for solutions, I began to wonder if the solution could be much simpler than I (or anyone else, it seems) was thinking.

Details πŸ”—

I’ll spare any reader the record of attempts, mistakes, other attempts, more mistakes, etc., and just get to the final workflow. I wrote a small script (in my case a function in Fish) that creates three files. One for the presentation, one for the article, and one for shared content. After creating the files, it opens a Dired buffer of the relevant folder in Emacs.

For those who use the Fish shell, here is the function:

function lecture
    touch {$argv}.org
    echo -e '#+startup: beamer' \n'#+TITLE: ' \n'#+AUTHOR: Dr. Ridenour' \n'#+DATE: ' >>{$argv}.org
    touch {$argv}-beamer.org
    cat /Users/rlridenour/Dropbox/emacs/beamer/lecture-beamer.org >{$argv}-beamer.org
    echo -e '#+include: "'{$argv}'.org" :minlevel 1' >>{$argv}-beamer.org
    touch {$argv}-notes.org
    cat /Users/rlridenour/Dropbox/emacs/beamer/lecture-notes.org >{$argv}-notes.org
    echo -e '#+include: "'{$argv}'.org" :minlevel 1' >>{$argv}-notes.org

So, entering “lecture kant” in the shell will open a Dired buffer containg the files kant.org, kant-beamer.org, and kant-notes.org.

Contents File πŸ”—

The contents file is a standard org file. Initially, I had it containing nothing in the header, except for possibly one line containing #+startup: beamer, which makes it easier to insert some Beamer-specific commands. After getting tired of entering the same data twice in the other files, I wondered if shared header information could just be placed in the contents file. Occasionally things work exactly how hoped they would, so no the function adds the following lines at the top of the contents file:

#+startup: beamer
#+AUTHOR: Dr. Ridenour

You will need to decide what heading level will designate a slide. Don’t worry, you’ll still be able to use that heading level in the article, as I’ll explain later. I use h3, so slides begin with a line like this in the contents file:

*** Slide Title

To add notes, you need to structurally separate the note content, which should only be printed on the article, from the preceding slide. To do this, add another h3 heading (I creatively title it “Notes”) with instructions to ignore the heading:

*** Notes :B_ignoreheading:
:BEAMER_env: ignoreheading

Any text that follows will only appear in the article, not in the presentation. This does not have to be done for every successive note paragraph, it only needs to be done after a slide. So, any paragraphs that are in the scope of an h1 or h2 heading won’t need that.

Presentation File πŸ”—

The magic happens with two small files. The first is the presentation file. At the top, put your preferred Beamer export header, but be sure to include #+LaTeX_CLASS_options: [ignorenonframetext] and #+OPTIONS: toc:nil. The latter is to ensure that Beamer export doesn’t make the contents slide before the presentation title slide. Then, make the title page like this:


If you want a table of contents slide, you can do the same thing except use \tableofcontents. Finally, include the contents file with this line:

#+include: "contents.org" :minlevel 1 

I keep the header information in two files in Dropbox. The Fish function adds the header, the title and table of contents lines, and the link to the contents file automatically.

Article File πŸ”—

For the article, use your preferred header with all of the packages declared, but be sure to add this line: #+LaTeX_HEADER: \usepackage{beamerarticle}. After the export header lines, include the contents file, again using #+include: "contents.org" :minlevel 1. When exporting, be sure to export with the one of the Beamer-specific exports. Otherwise, things just won’t look right.

Conclusion πŸ”—

There is one remaining problem that I have: the verse environment won’t work in beamerarticle. That’s a relatively small problem, though. I’m certainly not an Org mode expert, so if anyone has questions or suggestions, please let me know. I hope this saves at least one person some time.

A sample can be found on Github .

Emacs Org-Capture

May 12, 2020

When trying to post to a journal for the first time in an embarrassing number of months, I received an error that I had never had in the past: β€œorg-capture-select-template: Symbol’s function definition is void: org-mks.” A quick search revealed that it’s clearly defined in org.el, and I was successfully using org mode for other things, so I could see no reason for the error. A Google search revealed that several had the problem, but none of the proposed solutions worked.

In the end, it was a problem with my .emacs.d. I use an org-mode file, that is bootstrapped with an initialization file that requires org-install and on-tangle. Moving (package-initialize) to the first line of that file fixed the problem.

Thoughts on COVID-19

Mar 19, 2020

Here are some thoughts as I reflect on comments about, and available data on, the COVID-19 coronavirus.

I have seen some posts pointing out that 700 million people contracted H1N1 Swine Flue without any schools or businesses closing. The posts then go on to infer that COVID-19 has been “over-hyped.” There are several things to note as people decide how to appropriately respond to the pandemic, using the best numbers that I can find. H1N1 was indeed a serious pandemic, but the 700 million infected is not the only important number. H1N1 resulted in 150,000 fatalities (both of these numbers are minimum estimates), so the mortality rate for H1N1 was a mere 0.02%.

The mortality rate for COVID-19 is difficult to estimate, mainly because of the lack of adequate testing. Accurately estimating the mortality rate requires not only a decent estimate of the number of deaths from the infection, but also a good estimate of the total number of people infected. Without readily available tests, the tendency is to underestimate the number of people infected, which leads to an overestimation of the mortality rate. Early estimates were around 2%, then quickly rose to 3.4%, but now appear to be decreasing with more data. The best data comes from countries that tested a higher percentage of residents. So far, only 7 of every million residents of the U.S. have been tested, but South Korea’s rate of testing was over 150 times that of the U.S. The mortality rate in South Korea was only 0.6%, far lower than the estimates that we are hearing.

Good news for the COVID-19 skeptics? Not really, 0.6% is far lower than 2%, but it is 30 times greater than the mortality rate for H1N1. Even more important, we should only expect to have the 0.6% rate if we take the same steps as South Korea, which immediately set up a central disaster headquarters for a uniform and consistent response across the country, and ordered all schools from kindergarten through high school to postpone their spring semester. The mortality rate for Italy, also a country with a high testing percentage, is much higher. So far, the response to COVID-19 in the United States seems to be more like Italy than South Korea.

We should also compare COVID-19 to the SARS coronavirus. SARS killed 774 people in 2003, out of 8,096 known cases. The mortality rate for SARS, then, was a staggering 10%. Does that make SARS worse than COVID-19? We should keep in mind that there were only 8,096 known cases; there have now been over 45,000 known recoveries from COVID-19. The infection rate seems to be far, far greater with COVID-19.

Rational risk assessment is a function of two factors: the probability of harm and the degree of harm. Coronavirus wins the risk assessment game compared with both SARS and H1N1. The infection rate is far greater than that of SARS, and the mortality rate is far greater than that of H1N1.

Still, these numbers don’t apply to every population group. The mortality rate in China for children under 10 was 0%, for non-geriatric adults, it was 0.2–0.4%. The rates appear to significantly increase at 70 to 1.1%, then to 4.9% for those over 80. So, most of us have little or nothing to fear for ourselves from COVID-19, but those in high-risk groups, including the elderly and those with compromised immune systems, may have much to fear. The best way to save those people is to do everything we can to minimize the spreading of the virus, not just to them, but to anyone with whom they may have contact. The experience of other countries shows us that this requires these measures that motivate those negative social media posts.

There are those, not in high-risk groups, who may ask, “Why should we change our lifestyles if we are not personally at risk? Isn’t that just giving in to fear?” The answer is simple, we do these things not out of fear, but out of love for our neighbor.