Using Beamer and org mode to write slide shows

From Crashcourse Wiki

Jump to: navigation, search

Contents

[edit] Overview

A quick tutorial on how to use latex-beamer and emacs' "org mode" to write cool slide shows. All of this is explained in the context of my fully-updated 64-bit Ubuntu 12.04 system -- it should generalize to other distros fairly easily. Feedback to rpjday@crashcourse.ca.

WARNING: This tutorial was written from the perspective of a total org-mode newbie, so keep the muffled laughter to a minimum. :-)

[edit] Packages to install normally

If you simply install the pgf package, it will automatically pull in the necessary dependencies:

  • latex-xcolor
  • texlive-latex-base
Note that I *don't* install the latex-beamer package itself, since the Ubuntu package is somewhat behind the development version (3.10 versus 3.21). If you're happy with version 3.10, then just install it normally and skip the next couple sections.

If you want to be able to convert ASCII diagrams into proper bitmap graphics, you should install the ditaa package as well. I'm sure I'll think of other packages that will be useful.

[edit] Installing the development version of latex-beamer

Use Mercurial to check out the latest source somewhere in your home directory:

$ hg clone https://bitbucket.org/rivanvx/beamer
and then adjust it accordingly to get rid of SVN keywords that will mess things up later.

First, add the following to the .hg/hgrc file in the checked-out source:

[extensions]
keyword =
[keyword]
**.cls =
**.tex =
**.sty =
[keywordmaps]
Header = {root}/{file},v {node|short} {date|utcdate} {author|user}

then run the command:

$ hg kwexpand

At this point, sticking with your home directory, copy the entire base/ directory in the checked-out source to the directory ~/texmf/tex/latex/beamer/base/, and run:

$ texhash
so that tex knows about it. And that's it for the installation -- tex will now use your local installation of Beamer when processing Beamer files.

[edit] Testing your latex-beamer installation

From solutions/generic-talks/ in the checked out source, copy generic-ornate-15min-45min.en.tex to a work directory somewhere and run the following at least twice to generate the corresponding PDF file:

$ pdflatex generic-ornate-15min-45min.en.tex
and examine the resulting PDF output file. At this point, you've simply validated your latex-beamer processing. On to org-mode.

[edit] Updating org-mode

While all recent versions of emacs come with "org mode", it's typically out of date. You can see the current (built-in) version by typing M-x org-version, which will print something like Org-mode version 6.33x.

Simply install the current version:

$ sudo apt-get install org-mode
restart emacs, and run the same command to get Org-mode version 7.8.02.

[edit] Customizing emacs to export to Beamer

A number of handy explanations:

I'll just go with the first, simple one for now. I'm sure it will get more complicated over time.

[edit] Testing a simple example

Grab the .org file shown here, and save it as test.org. Here's the entire file (which includes an ASCII diagram):

#+MACRO: BEAMERMODE presentation
#+MACRO: BEAMERTHEME Antibes

#+MACRO: BEAMERCOLORTHEME lily
#+MACRO: BEAMERSUBJECT RMRF
#+MACRO: BEAMERINSTITUTE Miskatonic University, Astrology Dept.
#+TITLE: Presentation with Org-Mode and Beamer
#+AUTHOR: Someone

* My presentation

** Overview

   1. Introduction

   2. Main part

   3. Questions


** Some interesting stuff

*** an important point

    - subpoint a

    - subpoint b

** Graphics

*** a picture

#+begin_ditaa blue.png -r -S
+---------+
| cBLU    |
|    +----+
|    |cPNK|
+----+----+
#+end_ditaa

*** another picture
#+LaTeX:\includegraphics{emacs.png}

** More interesting stuff

*** some C++ code
#+begin_LaTeX
\begin{lstlisting}[language=c]
for (int i = 1; i != 10; ++i)
    std::cout << i << ": hello, world!"
              << std::endl;
\end{lstlisting}
#+end_LaTeX

*** and some Python...

#+begin_LaTeX
\begin{lstlisting}[language=python]
for i in range(1,10):
        print i, "hello, world!"
\end{lstlisting}
#+end_LaTeX

Open that file in emacs, and type C-c C-e d to generate the output file test.pdf. And that's it.

The code sections don't render properly, but that can be fixed by using the emacs customization shown at the emacs-fu site -- that makes things much better. I'll keep tweaking the customization as I understand it better.

[edit] Org mode and outlines

The whole reason I like this mode is that it gives me the chance to expand and collapse sections while in emacs -- just go to any section/subsection and hit TAB to either expand or collapse it. That's the way I write manuals -- work in one place, finish up there, close it, move elsewhere, open it up, etc.

Personal tools