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