Presentation with org beamer

From Software Heritage Wiki
Jump to: navigation, search

Presentation with org-beamer

org-mode (an emacs major mode) comes with a namespace \`ox-beamer\` which permits to export org-mode to pdf presentation using LaTeX's beamer package.

This permits using org-mode's simple markup to write presentations.

Pre-requisite

environment

We need

  • emacs
  • latex
  • latex's beamer package

Use your distribution's package manager to install those.

emacs setup

For inria, we need access to some latex macro that org does not know by default. This macro defines a \`picblock\` entry which permits to easily embed pictures with text.

Thus we need to extend emacs's org-beamer-mode:

   (require 'ox-beamer)
   
   (add-to-list 'org-beamer-environments-extra
                '("picblock"  "P" "\\begin{picblock}%o{%h}"      "\\end{picblock}"))

inria-presentation minor mode

For convenience here is a emacs minor mode to ease creating new presentation. Kill/Yank this snippet in your emacs configuration ~/.emacs.d/init.el for it to be loaded at emacs' startup time. When you want to create a presentation with beamer: M-x org-beamer-mode RET

   ;;; inria-presentation.el --- Default setup to create inria/irill presentation in org-mode  -*- lexical-binding: t; -*-
   
   ;; Copyright (C) 2015  inria irill
   
   ;; Author: ardumont <eniotna.t@gmail.com>
   ;; Keywords: convenience
   
   ;; This program is free software; you can redistribute it and/or modify
   ;; it under the terms of the GNU General Public License as published by
   ;; the Free Software Foundation, either version 3 of the License, or
   ;; (at your option) any later version.
   
   ;; This program is distributed in the hope that it will be useful,
   ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
   ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   ;; GNU General Public License for more details.
   
   ;; You should have received a copy of the GNU General Public License
   ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
   
   ;;; Commentary:
   
   ;; Depends on org-mode embedded in emacs as in at least emacs-24.3 and above
   
   ;;; Code:
   
   (require 'ox-beamer)
   
   ;; setup beamer-mode by adding a binding C-c C-b B to deal with picblock.
   (add-to-list 'org-beamer-environments-extra
                '("picblock"  "P" "\\begin{picblock}%o{%h}"      "\\end{picblock}"))
   
   (defun inria-presentation/template-headers-at-pt ()
     "Inject default template inside the current buffer.
   No intelligence whatsoever."
     (interactive)
     (with-current-buffer (buffer-name)
       (insert
        "# org export options
   #+LANGUAGE:  en
   #+OPTIONS:   H:2 num:t toc:t \\n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
   #+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
   #+EXPORT_SELECT_TAGS: export
   #+EXPORT_EXCLUDE_TAGS: noexport
   #+LINK_UP:
   #+LINK_HOME:
   
   # activate org-beamer-mode minor mode automatically
   #+STARTUP: beamer
   #+LaTeX_CLASS: beamer
   #+LaTeX_CLASS_OPTIONS: [presentation,xcolor=table]
   
   #+COLUMNS: %40ITEM %10BEAMER_env(Env) %9BEAMER_envargs(Env Args) %4BEAMER_col(Col) %10BEAMER_extra(Extra)
   
   # have the theme desired
   #+latex_header: \\mode<presentation>{\\usetheme{irill} \\beamertemplatenavigationsymbolsempty \\setbeamertemplate{navigation symbols}{} \\setbeamertemplate{headline}{} }
   
   # some color
   #+latex_header: \\rowcolors[]{1}{blue!10}{blue!05}
   
   # to have a toc for each section
   #+latex_header: \\AtBeginSection[] {\\begin{frame}<beamer> \\frametitle{Outline} \\tableofcontents[currentsection]\\end{frame} }
   
   # set the paths for images
   #+latex_header: \\graphicspath{{pics/}{../images/}{../../images/}{../pics/}{../../pics/}{../figures/}{../../figures/}{../logos/}{../../logos/}}
   
   # some default information I did not find how to set this in org-mode
   #+latex_header: \\institute[Irill/INRIA/UPD]{Présentation en ComDir\\\\ \\url{roberto@diiacosmo.org}\\\\ \\includegraphics[height=2cm]{SWH_logo_4-02b}}
   
   # to add the picblock macro
   #+latex_header: \\usepackage{extblocks}
   #+latex_header: \\usepackage{pgfpages}\n")))
   
   (defvar inria-presentation-mode-map
     (let ((map (make-sparse-keymap)))
       (define-key map (kbd "C-c g h") 'inria-presentation/template-headers-at-pt)
       map)
     "Inria-presentation's mode map.")
   
   ;;;###autoload
   (define-minor-mode inria-presentation-mode "Inria presentation mode."
     :lighter " IP"
     :keymap inria-presentation-mode-map)
   
   (add-hook 'org-beamer-mode-hook (lambda () (inria-presentation-mode)))
   
   (provide 'inria-presentation)
   ;;; inria-presentation.el ends here


Default template headers

Now we need to edit org-mode buffers to setup the pdf generation.

   #+TITLE: <title>
   #+AUTHOR: <author>
   #+DATE: <date-or-no-line-for-autogenerated-date>
   #+EMAIL: <email>
   #+DESCRIPTION: <some-description>
   #+KEYWORDS: <some-keywords>
   
   # org export options
   #+LANGUAGE:  en
   #+OPTIONS:   H:2 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
   #+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
   #+EXPORT_SELECT_TAGS: export
   #+EXPORT_EXCLUDE_TAGS: noexport
   #+LINK_UP:
   #+LINK_HOME:
   
   # activate org-beamer-mode minor mode automatically
   #+STARTUP: beamer
   #+LaTeX_CLASS: beamer
   #+LaTeX_CLASS_OPTIONS: [presentation,xcolor=table]
   
   #+COLUMNS: %40ITEM %10BEAMER_env(Env) %9BEAMER_envargs(Env Args) %4BEAMER_col(Col) %10BEAMER_extra(Extra)
   
   # have the theme desired
   #+latex_header: \mode<presentation>{\usetheme{irill} \beamertemplatenavigationsymbolsempty \setbeamertemplate{navigation symbols}{} \setbeamertemplate{headline}{} }
   
   # some color
   #+latex_header: \rowcolors[]{1}{blue!10}{blue!05}
   
   # to have a toc for each section
   #+latex_header: \AtBeginSection[] {\begin{frame}<beamer> \frametitle{Outline} \tableofcontents[currentsection]\end{frame} }
   
   # set the paths for images
   #+latex_header: \graphicspath{{pics/}{../images/}{../../images/}{../pics/}{../../pics/}{../figures/}{../../figures/}{../logos/}{../../logos/}}
   
   # some default information I did not find how to set this in org-mode
   #+latex_header: \institute[Irill/INRIA/UPD]{Présentation en ComDir\\ \url{roberto@dicosmo.org}\\ \includegraphics[height=2cm]{SWH_logo_4-02b}}
   
   # to add the picblock macro
   #+latex_header: \usepackage{extblocks}
   #+latex_header: \usepackage{pgfpages}

sources