Release 0.12: set version number to 0.12
[docutils.git] / sandbox / rst2beamer / docs / MANUAL.txt
blob9f5f57510da63f8a096602c31e2957d6e0716dec
1 =====================
2 The rst2beamer manual
3 =====================
5 .. warning::
7         This manual is disgracefully incomplete.
10 Introduction
11 ------------
13 In brief
14 ~~~~~~~~
16 rst2beamer is a docutils script that converts restructured text into
17 Beamer-flavoured LaTeX.
19 In more detail, Beamer is a LaTeX document class for presentations. rst2beamer
20 [#homepage]_ provides a Docutils [#docutils]_ writer that transforms a simple
21 text format called restructured text or ReST [#rst]_ into Beamer-flavoured
22 LaTeX. A commandline script is installed that therefore allows ReST to be used
23 to prepare slides and presentations. So a user can write a simple text file
24 that can be converted into LaTeX (and hence PDF or Postscript), in order to
25 quickly produce neat, professional presentations with a neat unified look.
28 What rst2beamer is (and isn't) for
29 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 rst2beamer was developed when one of us (PMA) grew frustrated with the length
32 of time it took to prepare a presentation for teaching, even simple slides
33 with bullet-pointed text and lumps of code. Preparing handouts or downloadable
34 versions was a further problem. rst2beamer was thus developed to quickly throw
35 together a structured presentation, with sections, titles and bullet points.
37 It is not a replacement for Powerpoint, Keynote or other graphical
38 presentation tools. Nor is it intended to be. While rst2beamer allows the
39 inclusion of images, if you need fancy transitions and navigation or complex
40 layout, you'd be better off with once of the aforementioned programs.
41 rst2beamer is meant to be:
43 * Quick: a presentation can be rapidly written, without slow and tedious
44   composition of pages and adjusting the position of page elements.
46 * Simple: the ReST syntax is easy to remember and write. The rst2beamer source
47   files can be easily read in their raw form.
49 * Portable: as the rst2beamer source files are plain text, they behave the
50   same across platforms. Also, by using the ReST syntax, presentations can be
51   easily converted to RTF, HTML and other formats.
53 Thus rst2beamer may be useful for teaching or conference presentations and has
54 been used at Python conferences for those purposes.
56 Conversely, rst2beamer doesn't do everything that Beamer or ReST can. Beamer
57 is a complex system that can make sophisticated presentations.
58 rst2beamer doesn't try to do everything that Beamer can, as this would foil
59 the goal of simplicity. Supported features include:
61 * Overlay lists (i.e. those that appear point-by-point)
62 * Beamer themes
63 * Automatic centering and resizing of figures
64 * Embedded notes and the output of note slides.
65 * Arranging slide contents into columns.
67 Some examples can be found in the ``docs/examples`` directory of the
68 distribution.
70 There may also be ReST syntax that doesn't work or looks bad in the beamer
71 output but most ReST should translate without problems.
74 Installation
75 ------------
77 rst2beamer can be installed in a number of ways. setuptools [#setuptools]_ is
78 preferred, but a manual installation will suffice.
80 Prerequisites
81 ~~~~~~~~~~~~~
83 rst2beamer requires the installation of the docutils package [#docutils]_.
84 Although older versions of docutils (e.g. v0.4) are useable, development
85 focuses on more recent version (e.g. v0.6).
88 Via setuptools / easy_install
89 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91 From the commandline call::
93         % easy_install rst2beamer
95 Superuser privileges may be required. 
98 Via setup.py
99 ~~~~~~~~~~~~
101 Download a source tarball, unpack it and call setup.py to install::
103         % tar zxvf rst2beamer.tgz
104         % cd rst2beamer
105         % python setup.py install
107 Superuser privileges may be required. 
110 Manual
111 ~~~~~~
113 Download and unpack the tarball as above. Ensure Docutils is available. Copy
114 the script ``rst2beamer.py`` to a location it can be called from.
117 Usage
118 -----
120 .. note::
122         Depending on your platform, the scripts may be installed as ``.py``
123         scripts, or some form of executable, or both.*
125 rst2beamer is called::
127   rst2beamer [options] [<source> [<destination>]]
129 For example, the simplest and typical way to use rst2beamer would be::
131         rst2beamer infile.txt outfile.tex
133 where ``infile.txt`` contains the ReST and ``outfile.tex`` contains the
134 produced Beamer LaTeX.
136 It supports the usual docutils and LaTeX writer (rst2latex) options, save the
137 ``documentclass`` option (which is fixed to ``beamer``) and hyperref options
138 (which are already set in beamer). It also supports:
140 --theme=THEME                           Specify Beamer theme.
141 --overlaybullets=OVERLAYBULLETS
142                                                                 Overlay bulleted items. Put [<+-| alert@+>] at the end
143                                                                 of \begin{itemize} so that Beamer creats an overlay
144                                                                 for each bulleted item and the presentation reveals
145                                                                 one bullet at a time
146 --centerfigs=CENTERFIGS
147                                                                 Center figures.  All includegraphics statements will
148                                                                 be put inside center environments.
149 --documentoptions=DOCUMENTOPTIONS
150                                                                 Specify document options. Multiple options can be
151                                                                 given, separated by commas.  Default is
152                                                                 "10pt,a4paper".
153 --shownotes=SHOWNOTES   Print embedded notes along with the slides. Possible
154                                                                 arguments include 'false' (don't show), 'only' (show
155                                                                 only notes), 'left', 'right', 'top', 'bottom' (show in
156                                                                 relation to the annotated slide).
158 Of course, rst2beamer only produces the LaTeX source for a presentation. LaTeX
159 hackers will have no difficulty using this, but most others will want to
160 convert immediately to PDF. This can be done easily with ``pdflatex``. For
161 example::
163         pdflatex outfile.tex
164         
165 will produce outfile.pdf. pdflatex is included in most TeX distributions.
168 Getting started
169 ---------------
171 TO BE COMPLETED
174 Themes
175 ------
177 Beamer can be displayed in a variety of themes, changing the sizing, color and
178 layout of page elements. The theme can be controlled by the commandline option
179 ``theme``. For example::
181         rst2beamer --theme=Rochester infile.rst
183 will produce a Beamer file styled with the "Rochester" theme. Some other
184 themes include "AnnArbor", "Bergen", "CambridgeUS" and "Warsaw".
186 .. note::
188         The selection of themes available with your LaTeX installation may vary
189         but a typical selection can be seen here [#beamer_themes]_. The default
190         Beamer theme (called "default") is very plain and so rst2beamer uses the
191         "Warsaw" theme as its default.
194 Sections
195 --------
197 Beamer supports the idea of grouping slides into sections and subsections.
198 rst2beamer allows this too, but frametitles must be in the lowest section
199 level. A section with no child sections is the lowest. Note that if you are
200 going to use subsections anywhere in the document but your first slide isn't
201 in a subsection, you have to use dummy a section before your first slide::
203         Introduction
204         ------------
206         dummy
207         ~~~~~
209         Slide 1
210         --------
212         - Point 1
213         - Point 2
215 The top level title is set as the presentation title while 2nd-level titles
216 are set as slide titles (``frametitles`` in Beamer terms). While all other
217 titles are converted as normal, Beamer ignores them. There is some problem in
218 the production of literals. rst2latex converts them to ragged-right, noindent
219 typewriter font in a quote. Under beamer however, this makes them appear as
220 italics. This was solved by overriding literal production with a simpler
221 enviroment, albeit one that occasionally produces buggy output. Options to
222 hyperref are dropped, due to this already being used in beamer.
226 Lists
227 -----
229 TO BE COMPLETED
232 Images
233 ------
235 Images default to being centered and having a height of 0.7\textheight (you
236 can turn off the centering with a commandline switch). Thus::
238         Slide Title
239         -----------
241         .. image :: image_name.png
243 produces a graph centered in the middle of the slide. Simple.
246 Columns
247 -------
249 Setting slide elements into columns teeters into the realm of page layout. If
250 layout is important, you may be better off using a more sophisticated
251 presentation tool. However, rst2beamer provides a few simple tools for quick
252 and consistent page layout into columns.
254 The simplest method is the r2b-simplecolumns directive. This will turn every
255 element underneath it into a column, side by side with each other. Individual
256 column width will be divided evenly from the total available, which by default
257 is set to 0.90 of the page width. The directive accepts an optional argument
258 ``width`` that that can be used to set this total. So this::
260         .. r2b-simplecolumns::
261                 :width: 0.95
263                 This is a demonstration of the rst2beamer simple
264                 column directive.
265         
266                 Notice that we have used the optional argument,
267                 "width". It is set to 0.95.
268         
269                 * A list or image
270                 * can be
271                 * a column
272                 
273 will produce a slide with three columns, containing the first, then second
274 paragraph, then the list. Their individual width will be 0.95 divided by
275 three.
277 However, custom r2b directives won't be recognised by any writer other than
278 rst2beamer. It would be lose the ability to turn your presentation into other
279 formats like HTML, etc. Therefore, we allow containers with certain names to
280 act like column sets. Most other writers should recognise these containers and
281 at worst ignore them rather than throw an error. For example::
283         .. container:: r2b-simplecolumns
285                 The custom r2b directives won't be recognised by any
286                 writer other than rst2beamer. 
288                 So, any container with the name 'r2b-simplecolumns'
289                 or 'r2b-simplecolumns' will be handled like the simple
290                 columns directive. 
293 Finally, we allow columns to be explicitly set and their width controlled with
294 the r2b-columnset and r2b-column directives. For example::
296         .. r2b-columnset::
297                 :width: 0.95
299                 .. r2b-column::
300                         :width: 0.60
301                 
302                         If you insist on setting columns explicitly, you can,
303                         grouping multiple elements.
304                 
305                         The width of the column set and individual columns can
306                         be given. This set and column are 0.95 and 0.60 wide
307                         respectively.
308                 
309                 .. r2b-column::
310         
311                         Columns not given a width (like this one) share the
312                         remainder.
314 A set of columns is indicated with the directive ``r2b-columnset``. It takes
315 the optional argument ``width``, which indicates the total page width the
316 contained columns will take up. Again, by default it is 0.90.
318 Only ``r2b-column`` directives can occur directly within a columnset. These
319 group one or more text elements to appear within a single column. They can
320 take an optional argument ``width``, which indicates how wide that column is.
321 Any unsized columns will be given a width from sharing the unallocated width
322 of the columnset. Overallocating width (i.e. columns accounting for more width
323 than available) will cause an error.
325 In all cases, columns may not be nested within columns more columnsets within
326 columnsets.
329 Notes
330 -----
332 Beamer support the inclusion of notes in a presentation. These are written as
333 text embedded in the main presentation, but usually invisible. When notes are
334 made visible, they are printed in another "slide" alongside the annotated
335 slide page.
337 rst2beamer supports the inclusion and showing of notes. Their appearance is
338 set with the commandline argument ``--shownotes``. For example::
340         rst2beamer --shownotes <option> mypresentation.rst
342 where ``option`` can be:
344         false
345                 don't show any notes (the default)
346                 
347         true
348                 show notes as per ``right``
349                         
350         only
351                 show only the notes, not the presentation
352                 
353         left, right, top, bottom
354                 show the notes in the given position to the presentation 
356 Notes can be included in ReST with the ``r2b-note`` directive. For example::
358         .. r2b-note::
360                 This is an example.
362 will inject a note into the current slide. Multiple notes can be included in
363 one slide and will be compiled into a single note. For example::
365         Farnarkling history
366         
367         .. r2b-note::
369                 Don't forget to mention the Sorenson brothers.
370         
371         Greats of the sport
372         
373         .. r2b-note::
375                 They would arkle with great authority.
376         
377 will produce a slide with the content:
379         Farnarkling history
381         Greats of the sport
383 and the accompanying note (normally hidden):
385         Don't forget to mention the Sorenson brothers.
387         They would arkle with great authority.
389 If notes are being shown, and a slide has no notes, the note page will simply
390 be empty.
392 Again, the custom r2b directives won't be recognised by any writer other than
393 rst2beamer, so we allow certain containers to act like notes::
395         .. container:: r2b-note
397                 Compatibility is important
399 Any container with the name 'r2b-note' will be handled like the notes
400 directive::
402         .. container:: r2b-note
404                 This will be understood by other ReST writers.
406 .. note::
408         See the "notes" input and output example files.
411 Codeblocks
412 ----------
414 Many presentations will need to display programming code. ReST already allows sourcecode to be included with the literal environment::
416    ::
418         def myfunc (arg1, arg2='foo'):
419                 global baz
420                 bar = unicode (quux)
421                 return 25
423 rst2beamer improves on this with ``code-block`` directive. In the simplest use, ``code-block`` (or it's synonym, ``sourcecode``) duplicates the literal enviroment::
425    .. code-block::
427         def myfunc (arg1, arg2='foo'):
428                 global baz
429                 bar = unicode (quux)
430                 return 25
432 However, if the Pygments syntax coloring library is installed, and the commandline argument ``--codeblocks-use-pygments`` is used, keywords and syntax will be highlighted in a language appropriate manner.
434 The language is specified by a optional argument to ``code-block``::
436    .. code-block:: python
437    
438 The language abbreviation is any of the "names" recognised by Pygments, which for the most part are common sense (e.g. *perl*, *cpp*, *java*). If the language is not provided, it is deduced in two ways. First if the commandline argument ``--codeblocks-default-language`` has been used, it sets the language for any unspecified codeblocks. Otherwise, the code is parsed in an attempt to deduce its type.
440 If tabs are used for indenting in a ReST source document, code can appear overly spread out (8 spaces per tabs). The ``--codeblocks-replace-tabs`` commandline option can be used to set the leading tabs in a codeblock ot a different number of spaces.
442 .. caution::
444    There are potential traps in adjusting codeblock tabs. ReST translates tabs
445    to 8 spaces upon reading, so the readjustment of tabs to a different size
446    necessitates reading in a stretch of indenting spaces, dividing it into
447    "tabs" and then replacing those with a different stretch of spaces. Thus,
448    mixing tabs with space is - as always - a bad idea, and replacing tabs on
449    a document indented with spaces is even worse.
452 Tips, tricks and limitations
453 ----------------------------
455 Just like Python, ReST relies on indentation for syntax (e.g. the arguments
456 and content of directives). But be careful not creates indents with a with
457 spaces and tabs. If you do, errors can occur that are difficult to diagnose as
458 blocks will *appear* to be correctly indented.
460 As is normal for LaTeX, it may be necessary to run it twice over rst2beamer
461 output for the the result to properly reflect the source file, if certain
462 structures (like sections) have been changed.
464 Following a double-colon (for preformatting) with a parsed-literal block like
465 below won't raise any error, but will result in malformed and incorrectly
466 formatted output::
468         Do not do this::
469         
470         .. parsed-literal::
472                 *for* i in *xrange* (10):
473                         *print* "foo", i
476 Earlier versions of rst2beamer did not work with docutils 0.4, seemingly due
477 to changes in the LaTeX writer. While this has been fixed, most work has been
478 done with docutils snapshots from version 0.5 and up. In balance, users are
479 recommended to keep docutils updated. More recently, changes in the LaTeX writer in docutils 0.6 broke rst2beamer again. We believe all those bugs have been caught.
481 Not all features of beamer are supported, and some - that deal with with page
482 layout or presentation - may never be. Introducing complex syntax to achieve
483 complex and specific page effects defeats the point of ReST's simple and
484 easy-to-write format. If you need a complex presentation, use Powerpoint or
485 Keynote.
487 If the content for an individual slide is too large, it will simply overflow
488 the edges of the slide and disappear. This usually occurs with large or long blocks of literal text that LaTeX is unable to wrap or reshape suitably. Arguably, this is a sign you should put less on each slide.
490 Getting your sections and frames confused (by being inconsistent about the titling style) can lead to cryptic LaTeX errors: "Runaway argument? File ended while scanning ..."
493 Development notes
494 -----------------
496 History & motivation
497 ~~~~~~~~~~~~~~~~~~~~
499 While preparing a course, one of us (PMA) became frustrated with the length of
500 time it took to prepare a presentation for teaching, even simple slides with
501 bullet-pointed text and lumps of code. Preparing handouts or downloadable
502 versions was a further problem. Given that docutils already has good LaTeX
503 output, PDF production via the Beamer document class was a logical choice.
504 rst2beamer started as a semi-ugly hack of docutil's LaTeX machinery, making as
505 few modifications are possible due to (a) laziness and (b) wanting to leverage
506 as much of an existing robust code base as possible. It wasn't - and isn't -
507 intended to be feature-complete: it worked with the ReST that I prepared and
508 will probably give adequate output for most other simple ReST documents. It
509 was subsequently taken up by the other of us (RK) who whipped the hacky script
510 into shape and added several features to make the produced slides far more
511 presentable. Unbeknownst to either of us, it seems to have been adopted by
512 Pythonistas for use at conferences.
515 Alternatives
516 ~~~~~~~~~~~~
518 Other presentation formats were considered as output options for ReST and discarded as follows:
520 * **ReportLab's Pythonpoint** requires a fixed frame size and would need
521   custom XML output. Styling is done through Reportlab stylesheets, which can
522   be complex.
524 * **Prosper** is another LaTeX solution. On balance, Beamer seemed better
525   although the point is arguable.
527 * **AxPoint** requires Perl.
529 * **slides and foil** are old LaTeX solutions that are now somewhat creaky.
531 A few other restructured text writers for presentation are available:
533 * **rst2beamer:** A later project of the same name is present in the docutils
534   sandbox. It seems to be a simple wrapper around the standard LaTeX writer
535   (much as this project started as) and may not support more beamer specific
536   syntax. Reports from anyone who has used it would be welcome.
538 * **s5:** A ReST-to-S5 writer is present in the standard docutils
539   distribution. It produces some very nice presentations with good visual
540   effects, although arguably at the cost of some very specific syntax. Those
541   who find rst2beamer underpowered might do well to look here.
544 Credits
545 ~~~~~~~
547 rst2beamer is developed by `Ryan Krauss <ryanwkrauss@gmail.com>`__ and
548 `Paul-Michael Agapow <agapow@bbsrc.ac.uk>`__. Thanks to those who reported and
549 helped us track down bugs: Perttu Laurinen, Mike Pennington, James Haggerty
550 and Dale Hathaway.
553 References
554 ----------
556 .. [#homepage] rst2beamer homepages at `agapow.net
557         <http://www.agapow/net/software/rst2beamer>`__ and `cs.siue.edu
558         <http://home.cs.siue.edu/rkrauss/python_website/>`__
560 .. [#setuptools] `Installing setuptools
561         <http://peak.telecommunity.com/DevCenter/setuptools#installing-setuptools>`__
563 .. [#docutils] `Docutils homepage <http://docutils.sourceforge.net/>`__
565 .. [#rst] `Restructured text <http://docutils.sourceforge.net/rst.html>`__
567 .. [#beamer] `Beamer homepage <http://latex-beamer.sourceforge.net/>`__
569 .. [#beamer_themes] Patrick Pletscher `Beamer Themes
570         <http://www.pletscher.org/writings/latex/beamerthemes.php>`__