Fix typo
[Worg.git] / org-tutorials / org-beamer / tutorial.org
blob0376fd72cc6ec5af4ab0ce894dfc3a9942a20301
1 #+TITLE:     Writing Beamer presentations in org-mode
2 #+AUTHOR:    Eric S Fraga
3 #+EMAIL:     e.fraga@ucl.ac.uk
4 #+DATE:      2010-10-02 Sat
5 #+DESCRIPTION: 
6 #+KEYWORDS: 
7 #+LANGUAGE:  en
8 #+OPTIONS:   H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
9 #+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
10 #+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
11 #+EXPORT_SELECT_TAGS: export
12 #+EXPORT_EXCLUDE_TAGS: noexport
13 #+LINK_UP:   
14 #+LINK_HOME: 
16 #+startup: oddeven
18 * Introduction
20 Beamer is a LaTeX package for writing presentations.  This documents
21 presents a simple introduction to preparing beamer presentations using
22 [[http://orgmode.org/][org-mode]] in Emacs.
24 This documents assumes that the reader is already acquainted with org-mode
25 itself and with *exporting* org-mode documents to LaTeX.  There are tutorials
26 and references available for both org-mode itself, for
27 [[http://orgmode.org/manual/Exporting.html#Exporting][LaTeX exporting]], and
28 for
29 [[http://orgmode.org/manual/Beamer-class-export.html#Beamer-class-export][Beamer
30 Class Export]].  The document also assumes that the reader understands the
31 notation for
32 [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Commands.html#Commands][Emacs
33 keybindings]].
35 * First steps
36 ** The export template
37 Starting with an empty file called =presentation.org= [1], say, the
38 first step is to insert the default org export template (=C-c C-e t=
39 with the default keybindings). This will generate something that looks
40 like this (some specific entries will vary):
42 #+BEGIN_Example
43 ,#+TITLE:     Writing Beamer presentations in org-mode
44 ,#+AUTHOR:    Eric S Fraga
45 ,#+EMAIL:     e.fraga@ucl.ac.uk
46 ,#+DATE:      2010-03-30 Tue
47 ,#+DESCRIPTION: 
48 ,#+KEYWORDS: 
49 ,#+LANGUAGE:  en
50 ,#+OPTIONS:   H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
51 ,#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
52 ,#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
53 ,#+EXPORT_SELECT_TAGS: export
54 ,#+EXPORT_EXCLUDE_TAGS: noexport
55 ,#+LINK_UP:   
56 ,#+LINK_HOME: 
57 #+END_Example
59 In this default template, you will want to modify, at the very least,
60 the title, as I have done, as this will be used as the title of your
61 presentation.  It will often be useful to modify some of the LaTeX
62 export options, most commonly the =toc= option for generating a table
63 of contents.  For this document, and the [[file:presentation.org][associated sample
64 presentation]], I have left all options as they are by default according
65 to the template.
66 ** Beamer specific settings
67 As well as the general options provided by the template, there are
68 Beamer specific options.  The following options are what I use:
70 #+BEGIN_Example
71 ,#+startup: beamer
72 ,#+LaTeX_CLASS: beamer
73 ,#+LaTeX_CLASS_OPTIONS: [bigger]
74 #+END_Example
76 The first line enables the Beamer specific commands for org-mode (more
77 on this below); the next two tell the LaTeX exporter to use the
78 Beamer class and to use the larger font settings[2].  
80 ** Outline levels for frames (slides)
82 The following line specifies how org headlines translate to the Beamer
83 document structure.
85 #+BEGIN_Example
86 ,#+BEAMER_FRAME_LEVEL: 2
87 #+END_Example
89 A Beamer presentation consists of a series of slides, called /frames/
90 in Beamer.  If the option shown above has a value of 1, each top level
91 headline will be translated into a frame.  Beamer, however, also makes
92 use of LaTeX sectioning to group frames.  If this appeals, setting
93 the option to a value of 2 tells org to export second level headlines
94 as frames with top level headlines translating to sections.
95 ** Column view for slide and block customisation
96 The final line that is useful to specify to set up the presentation is
98 #+BEGIN_Example
99 ,#+COLUMNS: %40ITEM %10BEAMER_env(Env) %9BEAMER_envargs(Env Args) %4BEAMER_col(Col) %10BEAMER_extra(Extra)
100 #+END_Example
102 The purposes of this line is to specify the format for the special
103 interface that org-mode provides to control the layout of individual
104 slides.  More on this below.
106 Once all of the above has been set up, you are ready to write your
107 presentation.
109 * The slides
111 Each slide, or /frame/ in Beamer terminology, consists of a title and
112 the content.  The title will be derived from the outline headline text
113 and the content will simply be the content that follows that
114 headline.  A few example slides are presented below.  These will only
115 cover the basic needs; for more complex examples and possible
116 customisations, I refer you to the [[http://orgmode.org/worg/org-tutorials/org-beamer.html][detailed manual]].
118 ** A simple slide
119 The simplest slide will consist of a title and some text.  For instance,
121 #+BEGIN_Example
122 ,* Introduction
123 ,** A simple slide
124 This slide consists of some text with a number of bullet points:
126 - the first, very @important@, point!
127 - the previous point shows the use of the special markup which
128   translates to the Beamer specific /alert/ command for highlighting
129   text.
132 The above list could be numbered or any other type of list and may
133 include sub-lists.
134 #+END_Example
136 defines a new section, /Introduction/, which has a slide with title
137 /A simple slide/ and a three item list.  The result of this with the
138 settings defined above, mostly default settings, will generate a slide
139 that looks like this:
141 #+caption: Simple slide exported from org to LaTeX using beamer
142 [[file:../../images/org-beamer/a-simple-slide.png]]
144 ** A more complex slide using blocks
146 Beamer has the concept of block, a set of text that is logically
147 together but apart from the rest of the text that may be in a slide.
148 How blocks are presented will depend on the Beamer theme used
149 ([[*Customisation][customisation in general]] and [[*Beamer%20theme][choosing the theme specifically]] are
150 described below).
152 There are many types of blocks.  The following
154 #+BEGIN_Example
155 ,** A more complex slide
156 This slide illustrates the use of Beamer blocks.  The following text,
157 with its own headline, is displayed in a block:
158 ,*** Org mode increases productivity                               :B_theorem:
159     :PROPERTIES:
160     :BEAMER_env: theorem
161     :END:
162     - org mode means not having to remember LaTeX commands.
163     - it is based on ascii text which is inherently portable.
164     - Emacs!
166     \hfill \(\qed\)
167 #+END_Example
169 creates a slide that has a title (the headline text), a couple of
170 sentences in paragraph format and then a /theorem/ block (in which I
171 prove that org increases productivity).  The theorem proof is a list
172 of points followed a bit of LaTeX code at the end to draw a fancy
173 /end of proof/ symbol right adjusted.
175 You will see that there is an org properties /drawer/ that tells org
176 that the text under this headline is a block and it also specifies the
177 type of block.  You do not have to enter this text directly yourself;
178 org-mode has a special beamer sub-mode which provides an easy to use
179 method for specifying block types (and columns as well, as we shall
180 [[*Column%20view%20for%20slide%20and%20block%20customisation][see in the next section]]).
182 To specify the type of block, you can type =C-c C-b=[3].  This brings up
183 a keyboard driven menu in which you type a single letter to select the
184 option you wish to apply to this headline.  For the above example, I
185 typed =C-c C-b t=.  The options selected in this manner are also shown
186 as /tags/ on the headline.  However, note that the tag is for display
187 only and has no direct effect on the presentation.  You cannot change
188 the behaviour by changing the tag; it is the property that controls
189 the behaviour.
191 ** Slides with columns
193 The previous section introduced the special access keys (=C-c C-b=)
194 for defining blocks.  This same interface allows you to define
195 columns.  A headline, as the text that follows it, can be in a block,
196 in a column, or both simutaneously.  The =|= option will define a
197 column.  The following
199 #+BEGIN_Example
200 ,** Two columns
202 ,*** A block                                           :B_ignoreheading:BMCOL:
203     :PROPERTIES:
204     :BEAMER_env: ignoreheading
205     :BEAMER_col: 0.4
206     :END:
207     - this slide consists of two columns
208     - the first (left) column has no heading and consists of text
209     - the second (right) column has an image and is enclosed in an
210       @example@ block
212 ,*** A screenshot                                            :BMCOL:B_example:
213     :PROPERTIES:
214     :BEAMER_col: 0.6
215     :BEAMER_env: example
216     :END:
217 ,    #+ATTR_LATEX: width=\textwidth
218     [[file://../../images/org-beamer/a-simple-slide.png]]
219 #+END_Example
221 defines a two column slide.  As the text in the slide says, the left
222 column is a list and the right one is an image.  The left column's
223 headline text is ignored, specified by =C-c C-b i= which tells org to
224 *ignore* the headline text completely.  The column on the right
225 however is placed with an /example/ block (whose appearance will
226 depend on the Beamer theme).
228 The columns also have widths.  By default, these widths are the
229 proportion of the page width to use so I have specified 40% for the
230 left column and 60% for the right one.
232 The image in the right column is inserted simply by specifying a link
233 to the image file with no descriptive text.  I have added an attribute
234 to the image (see the =#+ATTR_LATEX= line above) to tell LaTeX to scale
235 the image to the full width of the column (=\textwidth=).
237 ** Using Babel
238 One of my main uses for Beamer is the preparation of slides for
239 teaching.  I happen to teach [[http://www.octave.org/][Octave]] to engineering students.  Org
240 provides the [[http://orgmode.org/worg/org-contrib/babel/index.html][Babel]] framework for embedding code within org
241 files.  For teaching, this is an excellent tool for presenting codes
242 and the results of evaluating those codes.
244 For instance, the following code:
245 #+begin_example
246 ,** Babel
247    :PROPERTIES:
248    :BEAMER_envargs: [t]
249    :END:
250 ,*** Octave code                                                      :BMCOL:B_block:
251     :PROPERTIES:
252     :BEAMER_col: 0.45
253     :BEAMER_env: block
254     :END:
255 ,#+srcname: octaveexample
256 ,#+begin_src octave :results output :exports both
257 A = [1 2 ; 3 4]
258 b = [1; 1];
259 x = A\b
260 ,#+end_src
262 ,*** The output                                               :BMCOL:B_block:
263     :PROPERTIES:
264     :BEAMER_col: 0.4
265     :BEAMER_env: block
266     :BEAMER_envargs: <2->
267     :END:
269 ,#+results: octaveexample
270 ,#+begin_example
271 A =
273    1   2
274    3   4
276 x =
278   -1
279    1
281 ,#+end_example
283 #+end_example
285 will generate a slide with two blocks and a pause between the display
286 of each of the two blocks:
288 #+caption: The use of babel for code display and execution
289 [[file:../..//images/org-beamer/babel-octave.png]]
291 * Customisation
293 Org has a very large number of customisable aspects.  Although
294 daunting at first, most options have defaults that are suitable for
295 most people using org initially.  The same applies to the Beamer
296 export support.  However, there are some options which many will soon
297 wish to change.
299 ** Beamer theme
301 Beamer has a large number of themes and I simply refer the reader to
302 the manual or the Web to find what themes are available and what they
303 look like.  When you have chosen a theme, you can tell org to use it
304 by inserting some direct LaTeX code into the /preamble/ of the
305 document, the material that comes before the first headline.  For
306 instance, adding this line
307 #+BEGIN_Example
308 ,#+latex_header: \mode<beamer>{\usetheme{Madrid}}
309 #+END_Example
310 to the preamble after the beamer font size
311 option described above will produce a presentation that looks very
312 different from the default (with no other changes required!):
314 #+caption: Two column slide with the Madrid Beamer theme
315 [[file:../../images/org-beamer/two-column-slide-madrid-style.png]]
317 ** Table of contents
319 The default =toc:t= option generated by the [[*The%20export%20template][export template command]]
320 (=C-c C-e t=) indicates that a table of contents will be generated.
321 This will create a slide immediately after the title slide which will
322 have the list of sections in the beamer document.  Please note that if
323 you want this type of functionality, you will have to specify the
324 =BEAMER-FRAME-LEVEL= to be 2 instead of 1 [[Outline%20levels%20for%20frames%20(slides)][as indicated above]].
326 Furthermore, if you have decided to use sections, it is possible to
327 have Beamer automatically place a table of contents slide before the
328 start of each section with the new section highlighted.  This is
329 achieved by inserting the following LaTeX code, again in the
330 preamble:
331 #+BEGIN_Example
332 ,#+latex_header: \AtBeginSection[]{\begin{frame}<beamer>\frametitle{Topic}\tableofcontents[currentsection]\end{frame}}
333 #+END_Example
335 ** Column view for slide and block customisation
337 In [[*Column%20view%20for%20slide%20and%20block%20customisation][an early section of this document]], I described a magical
338 incantation!  This incantation defines the format for viewing org
339 property information in column mode.  This mode allows you to easily
340 adjust the values of the properties for any headline in your
341 document.  This image shows the type of information you can see at a
342 glance in this mode:
344 #+caption: Column view of presentation showing special block environments and column widths.
345 [[file:../../images/org-beamer/column-view.png]]
347 We can see the various blocks that have been defined as well as any
348 columns (implicit by the presence of a column width).  By moving to
349 any of these column entries displayed, values can be added, deleted or
350 changed easily.  Please read [[http://orgmode.org/manual/Beamer-class-export.html#Beamer-class-export][the full org Beamer manual]] for details.
352 * Footnotes
354 [1] [[http://orgmode.org/worg/sources/org-tutorials/org-beamer/presentation.org][A previously created example presentation]] is available.
356 [2] I am a firm believer in using the largest font possible to
357 encourage less text on slides. This is obviously a personal view.
359 [3] org-beamer-mode must be turned on for this keybinding to be available.