--- category: '' date: 2009/05/21 15:48 description: '' link: '' priority: '' slug: BBS52 tags: python, rst2pdf, open source title: Creating presentations using restructured text type: text updated: 2009/05/21 15:48 url_type: '' --- Suppose you are a nerd. Specifically, an open-source-using nerd. Who am I kidding, you are reading my blog, *of course* you are an open-source-using nerd. Let's try again: you are an open-source-using nerd who needs to do a presentation at your local LUG/programming language conference/Linux event/bar mitzvah. In that case, you probably want to show some slides. I am here to help you create your slides the nerd way. A regular guy would do them using, say, PowerPoint_ or a similar program like OOo's Impress_ However, since you are who you are, you know there are problems in that direction. 1) How do you keep a versioned history of such documents? (Yes, they are XML now. It's compressed so, unless you want to version-control the uncompressed... forget it, it's awful) 2) If you use one of those, and you have to use someone else's computer, he is bound to have installed the other. 3) You will feel dirty inside. 4) It's not *at all* like programming. You like programming. 5) It's completely separate from creating, for example, a handout, or a larger document that complements the slides. So, let's get unconventional. There are a bunch of presentation tools that don't have those problems, from MagicPoint_ to Prosper_ (or Beamer_), to Tobogan_ [1]_, to s5_ and others. All of them would be cool for you. But I think you can do better, because there are problems with them. * LaTeX (used with prosper or beamer): well, you need to know LaTeX. If you want code syntax highlighting you need another package. If you want to use your pet TT font it's not obvious, and the results are... not very inspiring_ for the amount of noise. Here's how you create a slide with four items in it in beamer: .. code-block:: latex \section{Section no. 2} \subsection{Lists I} \begin{frame}\frametitle{unnumbered lists} \begin{itemize} \item Introduction to \LaTeX \item Course 2 \item Termpapers and presentations with \LaTeX \item Beamer class \end{itemize} \end{frame} Personally I prefer my markup lighter. * MagicPoint: needs manuals. Really, really needs manuals. Also, it will create your slides, and nothing else. * s5: looks dead. It's nicer with rst2s5. And of course, the killer argument: if I were to recommend you use one of those, I wouldn't have bothered writing this! So, let's go to what I will do for my next conference: I will use a PDF. Specifically, I will use a PDF I built using rst2pdf_ [2]_ If you are not familiar with `reStructured Text`_ by all means follow that link and get acquainted, because it's the bet thing since sliced bread [3]_ [4]_ [5]_ . So, how do you create slides using rst2pdf? It's very simple. So simple, I will use an example file_. .. code-block:: rst This is my first slide ---------------------- * It has, of course, items in it * More than one item 1. Numbered lists, too This is my second slide ----------------------- rst2pdf can display code nicely: .. code-block:: python for x in range(7): print "cute!" This is my third slide ---------------------- Also, you can use math! .. math:: \frac{2 \pm \sqrt{7}}{3} That is *not* an image. This is my 4th slide -------------------- Other features include: * Images, including SVG * Tables * Font embedding (Type1 and TTF) * Extensible * Background (like this one) * Page transitions .. header:: Rst2pdf Slide Demo .. footer:: © Roberto Alsina, 2009 Now, that was not all that hard to grasp, was it? And what's the result? Here is the file seen in oKular_: .. raw:: html rst2pdfslides2 And here you can get `the PDF file`_ for yourself. Of course, you are noticing things in that image or PDF that are not in the code I posted above, like "where is the background coming from?" or "Where did he specify that funky aspect ratio?". Well, the answer is this stylesheet_: .. code-block:: js {"pageSetup": { "width": "16cm", "height": "9cm", "margin-top": "0cm", "margin-bottom": "0cm", "margin-left": "0cm", "margin-right": "0cm", "margin-gutter": "0cm", "spacing-header": "5mm", "spacing-footer": "5mm", "firstTemplate": "cutePage" }, "pageTemplates" : { "cutePage": { "frames": [ ["10%", "10%", "80%", "80%"] ], "background" : "background.svg" } } } The background.svg_ is done with inkscape_. And to go from these files to the PDF, this is the command:: rst2pdf slides.txt -b1 -s slides.style The ``-b1`` is so there is a page break after each section (that would be just before each title). You can show this PDF file with any PDF viewer, but I like Okular's presentation mode a lot, and if you want fancy, you could try Impressive_. Impressive can do neat page transitions, but if you like them [6]_ and prefer to use another PDF viewer, you can use rst2pdf's page transition support by adding something like this at the end of each section: .. code-block:: rst .. raw:: pdf Transition Split 1 90 I I won't tell you what that means, only aim you in the general direction of `the FM`_ And that's it. There's your slideshow. If you want to add things like a nice handout where you mix one slide / one page of text, that's not hard to do, but I wil leave it as an exercise to the reader. And if you use this... `let me know`_! .. _let me know: mailto:ralsina@netmanagers.com.ar .. _the FM: http://lateral.netmanagers.com.ar/static/manual.pdf .. _impressive: http://impressive.sourceforge.net/ .. _file: http://lateral.netmanagers.com.ar/static/rst2pdf-slides/slides.txt .. _stylesheet: http://lateral.netmanagers.com.ar/static/rst2pdf-slides/slides.style .. _background.svg: http://lateral.netmanagers.com.ar/static/rst2pdf-slides/background.svg .. _inkscape: http://www.inkscape.org/ .. _the PDF file: http://lateral.netmanagers.com.ar/static/rst2pdf-slides/slides.pdf .. _okular: http://okular.kde.org/ .. _restructured text: http://docutils.sourceforge.net/rst.html .. _rst2pdf: http://rst2pdf.googlecode.com .. _inspiring: http://www.informatik.uni-freiburg.de/~frank/ENG/beamer/example/Beamer-class-example8-AnnArbor.pdf .. _s5: http://meyerweb.com/eric/tools/s5/ .. _tobogan: http://code.google.com/p/tobogan/ .. _beamer: http://latex-beamer.sourceforge.net/ .. _prosper: http://amath.colorado.edu/documentation/LaTeX/prosper/ .. _magicpoint: http://member.wide.ad.jp/wg/mgp/ .. _impress: http://www.openoffice.org/product/impress.html .. _powerpoint: http://office.microsoft.com/en-us/powerpoint/default.aspx .. _sphinx: http://sphinx.pocoo.org/ ------------- .. [1] jaja, no, you didn't know that one. Only I know it because I *wrote* it. But don't worry, we will not be using it today. .. [2] Yes, I wrote most of rst2pdf. No, I am not impartial about it in any way. It's my baby! .. [3] Hell, have you ever tried documenting a server using sliced bread? It's hard! .. [4] It also means you are 90% there about learning how to use Sphinx_. .. [5] In fact, what's so awesome about sliced bread? It's 4 times more expensive as tastier, crusty, yummy bread. .. [6] Why? They are so 1997!