Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ReST, Pandoc, Beamer: My Slideshow Toolchain - BFPG

ReST, Pandoc, Beamer: My Slideshow Toolchain - BFPG

Video: https://www.youtube.com/watch?v=vE7cNe44l-4

Giving technical presentations is a worthwhile and satisfying endeavour, but producing a quality slide deck can be a frustrating and time consuming activity. It needn't be.

In this talk I will show you my slide toolchain which, in brief, turns ReStructuredText (a lightweight markup format) into a PDF via Pandoc (a "universal document converter" written in Haskell), allowing me to focus on the structure and content of my presentations and not worry about formatting.

We will cover basic formatting, math, code, images, Unicode, foreign scripts, slide appearance and themes, and how to escape from ReST and access the full power of LaTeX when needed. There will also be a brief detour into Pandoc internals and a discussion of ways to vary the toolchain for alternative markup language preferences or output formats.

7c0f9b056604fe541691e18aeb679cf7?s=128

Fraser Tweedale

March 09, 2016
Tweet

More Decks by Fraser Tweedale

Other Decks in Technology

Transcript

  1. [Pan]Dr. Slidelove or: How I Learned to Stop Worrying and

    Love the Beamer Fraser Tweedale @hackuador March 8, 2016
  2. Intro

  3. Motivation I do technical presentations I want nice looking presentations

    I want to focus on slide content—not formatting!
  4. Overview My slide toolchain Examples; live slide hacking Pandoc internals

    Not a L A TEX tutorial
  5. Toolchain Write slides in ReStructuredText format Fall back to L

    A TEX if/when needed Convert to PDF slideshow using Pandoc
  6. ReStructuredText ReST, *.rst Lightweight markup Originated from Python Docutils predates

    Markdown
  7. Pandoc “Universal document converter” Haskell GPLv2+

  8. Pandoc - running File ./build.sh: #!/bin/sh pandoc talk.rst --to=beamer -o

    slides.pdf \ --template=my.beamer \ --highlight-style=pygments \ --variable=title:"Dr. Slidelove" \ -V subtitle:"or: How I Learned to Stop Worrying and Love the Beamer" \ -V author:"Fraser Tweedale" \ -V date:"\\today" \ ...
  9. Pandoc - templates Each Pandoc writer has a default template

    pandoc --print-default-template=beamer > ... pandoc --template="my.beamer" Upgrades
  10. Examples

  11. Basic formatting (source) Basic formatting (output) ========================= .. comment (ignored)

    - **boldface** - *emphasis* - monospace - foo - bar
  12. Basic formatting (output) boldface emphasis monospace foo bar

  13. Hyperlinks (source) Hyperlinks (output) =================== - https://foo.com/ - Embedded link

    <https://bar.com/> _ - External link _ .. _External link: https://baz.com/
  14. Hyperlinks (output) https://foo.com/ Embedded link External link

  15. Incremental lists (source) Incremental lists (output) ========================== 1. one #.

    at #. a #. time
  16. Incremental lists (output) 1. one

  17. Incremental lists (output) 1. one 2. at

  18. Incremental lists (output) 1. one 2. at 3. a

  19. Incremental lists (output) 1. one 2. at 3. a 4.

    time
  20. Code (source) Code (output) ============= - Syntax highlighting via Pygments

    - >300 supported languages - http://pygments.org/docs/lexers/ .. code:: haskell -- | -- prop> rev [x] == [x] -- prop> rev (xs ++ ys) == rev ys ++ rev xs rev :: [a] -> [a] rev = foldl (flip (:)) []
  21. Code (output) Syntax highlighting via Pygments >300 supported languages http://pygments.org/docs/lexers/

    -- | -- prop> rev [x] == [x] -- prop> rev (xs ++ ys) == rev ys ++ rev xs rev :: [a] -> [a] rev = foldl (flip (:)) []
  22. Math - standalone (source) Math - standalone (output) ========================== ..

    math:: x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cfrac{1}{a_4} } } }
  23. Math - standalone (output) x = a0 + 1 a1

    + 1 a2 + 1 a3 + 1 a4
  24. Math - inline (source) Math - inline (output) ====================== -

    math role can be used inline - Like so: :math: {n! \over k!(n-k)!} = {n \choose k}
  25. Math - inline (output) math role can be used inline

    Like so: n! k!(n−k)! = n k
  26. Raw L A TEX - standalone (source) Raw :latex: {\LaTeX}

    - standalone (output) =========================================== .. raw:: latex \centering \begin{tabular}{|r|l|} \hline 7C0 & hexadecimal \\ 3700 & octal \\ \cline{2-2} 11111000000 & binary \\ \hline \hline 1984 & decimal \\ \hline \end{tabular}
  27. Raw L A TEX - standalone (output) 7C0 hexadecimal 3700

    octal 11111000000 binary 1984 decimal
  28. Raw L A TEX - inline (source) .. role:: latex(raw)

    :format: latex Raw :latex: {\LaTeX} - inline (output) ======================================= - Water = :latex: H\textsubscript{2}O - :latex: {\LaTeX} is \textnumero 1 \checkmark
  29. Raw L A TEX - inline (output) Water = H2

    O L A TEX is №1
  30. Images (source) Images (output) =============== .. image:: file_extensions.png :width: 40%

    :align: center CC BY-NC 2.5 https://xkcd.com/1301/
  31. Images (output) CC BY-NC 2.5 https://xkcd.com/1301/

  32. Unicode \usepackage[utf8]{inputenc} (Pandoc default) map Unicode characters to arbitrary L

    A TEX \DeclareUnicodeCharacter{2200}{$\forall$} \usepackage[utf8x]{inputenc} (edit template) loads a library of many predefined mappings LuaL A TEX supports direct UTF-8 input some “math” characters missing from text environment
  33. Beamer - title page Pandoc variables title, subtitle, author, date

    Can use raw L A TEX in values pandoc ... -V date:"\\today" Automatically added iff title variable is defined
  34. Beamer - appearance Use serif typeface for math \usefonttheme[onlymath]{serif} Colour

    hyperlinks \hypersetup{colorlinks,linkcolor=,urlcolor=purple} Include a logo \logo{\includegraphics[height=0.5cm]{logo.png}} Aspect ratio class option aspectratio={43,169,...}
  35. Beamer - themes Beamer has themes (layout) and colour themes

    https://www.hartwork.org/beamer-theme-matrix/ Pandoc variables: theme, colortheme
  36. Speaker notes (source) Speaker notes (output) ====================== - This slide

    has speaker notes - Compile with class option notes={show,only} .. class:: notes - This is a speaker note - Don t forget to mention X
  37. Speaker notes (output) This slide has speaker notes Compile with

    class option notes={show,only}
  38. Speaker notes (output) This slide has speaker notes Compile with

    class option notes={show,only} 2016-03-08 [Pan]Dr. Slidelove Examples Speaker notes (output) • This is a speaker note • Don’t forget to mention X
  39. Other approaches Other markup formats Raw Beamer with great power

    comes. . . more boilerplate! HTML+JS slideshows
  40. Pandoc internals

  41. Resources http://docutils.sourceforge.net/rst.html https://en.wikibooks.org/wiki/LaTeX https://tex.stackexchange.com/ https://ctan.org/pkg/beamer http://pandoc.org/

  42. Fin Copyright 2016 Fraser Tweedale This work is licensed under

    the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/. Slides https://speakerdeck.com/frasertweedale Twitter @hackuador Email ftweedal@redhat.com