Beamer Presentations with Org Mode

Presentations With Org

Introduction

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
    dired
end

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
#+TITLE:
#+AUTHOR: Dr. Ridenour
#+DATE:

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:
:PROPERTIES:
:BEAMER_env: ignoreheading
:END:

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:

***
\maketitle

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

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

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.

Some Thoughts on Mass Shootings

The Second Amendment

Despite the Supreme Court’s 2008 Heller decision, I have never thought that a reasonable reading of the 2nd Amendment guaranteed an individual’s unequivocal right to possess firearms. In fact, the only Supreme Court decision that focused on the 2nd Amendment, US vs. Miller in 1939, found that there is no individual right to bear arms independent of the nation’s self-defense interests. There is also reason to believe that Madison wrote the 2nd Amendment to protect the rights of southern states to have militias that they could use to put down slave revolts. 1

I do believe, however, that every person has an inherent right to self-defense. 2 I take this to not be a civil right enshrined in law, but as a basic human right. Although there are weapons that are designed to be used for defensive roles, assault rifles, by definition, are not. I have no sympathy for those who argue that their guns are necessary for defense against a tyrannical government. I have seen four Apache helicopters on an attack run at a range in Fort Hood. If you think that your AR-15 will defend you, you’ve been watching too many bad action movies. 3

Good Guys with Guns

Lately, there have been demands to arm teachers to prevent school shootings. This is a variation on the idea that the only solution to gun violence is more good guys with guns. There are obvious reasons why this is untenable. We had problems with active shooters when I was in Afghanistan. The solution was not to have more people carrying guns, since everyone except me and the other two chaplains were already armed. The solution was to have a soldier standing at the ready at every meeting, doing nothing but looking for signs of hostility, prepared to shoot as soon as a weapon was drawn. That’s what the only “more guns” solution looks like – an armed guard standing with weapon drawn in every classroom, in every corridor of the mall, covering every line of sight in every public venue, etc. 4 That’s not a country where I want to live.

Possible Solutions

Mass shootings are a complex problem, but not irreducibly complex. We shouldn’t pretend that our only options are an impossible perfect solution and doing nothing. So, what should be done? There are some means that, I believe, would help reduce the level of gun violence.

  1. Treating sources of terrorism consistently would be a good first step. White nationalism has always been an ideology associated with terrorism, from the lynchings of Reconstruction to the mass shooting in El Paso. As a terrorist ideology, white nationalist demands for racial purity are no different than demands for religious purity from other movements that we rightly label as terrorists.
  2. Ban assault weapons – that has already been shown to be effective.
  3. Ban high capacity magazines. Otherwise, thirty people are dead before the “good guy with a gun” has an opportunity to respond.

May God forgive me, if I ever demand my rights at the possible expense of another human being’s life.

  1. Conservatives had no problem with gun control when the Black Panthers were taking up arms to press for equal civil rights. As Governor of California, Ronald Reagan signed an act in 1967 banning the carrying by members of the public of loaded firearms in cities. He said there is “no reason why on the street today a citizen should be carrying loaded weapons.” It’s also curious how reticent the NRA is to come to the defense of registered African-American gun owners.
  2. Specifying this right will, by no means, be simple. I do not believe that people have the right to do anything that will result in saving their lives. I also do not believe that the right to self-defense is automatically a right to kill, if there are other effective means available. There are also tricky questions about prisoners on death row, etc. This is also a right that implies certain duties, like the duty to ensure, as much as possible, that no innocent people are harmed. This means that gun-owners have a duty to acquire and maintain a high level of skill. This could mean that the public has a right to demand that those who wish to carry firearms in public be tested and certified.
  3. I’ve also recently heard that when criminals get semi-automatic weapons, then citizens need full-auto. In my infantry days, the only situation in which fully automatic fire was used was to spray a room with bullets before entering. So, saying this is the same as saying “When criminals get semi-auto, then citizens kill indiscriminately.”
  4. That doesn’t mean that a member of the public with a gun will not occasionally act to prevent, or minimize, some tragedy. That will have to be weighed against members of the public misidentifying a target or harm done by negligent discharges, a particular problem that we had in Iraq.

Free Shows in the Hospital

The RN today told me a story about a 90 year old man he was supposed to take down the hall in the hospital. The man got out of bed himself and started walking down the hall in his hospital gown. The nurse ran up to him and said “Your back door is open!” The man replied, “That’s why there’s a pocket on the gown – for all the tips.”

I won’t discuss the situation today that prompted his telling me that story though.