org.texi (Installation): Detail instructions when installing through ELPA
[org-mode.git] / lisp / ox-beamer.el
blob282da7c9f60af6da37abb81720a1be945376aaff
1 ;;; ox-beamer.el --- Beamer Back-End for Org Export Engine
3 ;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
6 ;; Nicolas Goaziou <n.goaziou AT gmail DOT com>
7 ;; Keywords: org, wp, tex
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;; This library implements both a Beamer back-end, derived from the
25 ;; LaTeX one and a minor mode easing structure edition of the
26 ;; document.
28 ;; Depending on the desired output format, three commands are provided
29 ;; for export: `org-beamer-export-as-latex' (temporary buffer),
30 ;; `org-beamer-export-to-latex' ("tex" file) and
31 ;; `org-beamer-export-to-pdf' ("pdf" file).
33 ;; This back-end supports every buffer keyword, attribute and options
34 ;; items (see `org-latex-options-alist') already supported by `latex'
35 ;; back-end. As such, it is suggested to add an entry in
36 ;; `org-latex-classes' variable which is appropriate for Beamer
37 ;; export.
39 ;; On top of this, the `beamer' back-end also introduces the following
40 ;; keywords: "BEAMER_THEME", "BEAMER_COLOR_THEME",
41 ;; "BEAMER_FONT_THEME", "BEAMER_INNER_THEME", "BEAMER_OUTER_THEME" and
42 ;; "BEAMER_HEADER". All but the latter accept options in square
43 ;; brackets.
45 ;; Moreover, headlines now fall into three categories: sectioning
46 ;; elements, frames and blocks.
48 ;; - Headlines become frames when their level is equal to
49 ;; `org-beamer-frame-level' (or "H" value in the OPTIONS line).
50 ;; Though, if a headline in the current tree has a "BEAMER_env"
51 ;; (see below) property set to either "frame" or "fullframe", its
52 ;; level overrides the variable. A "fullframe" is a frame with an
53 ;; empty (ignored) title.
55 ;; - All frames' children become block environments. Special block
56 ;; types can be enforced by setting headline's "BEAMER_env" property
57 ;; to an appropriate value (see `org-beamer-environments-default'
58 ;; for supported value and `org-beamer-environments-extra' for
59 ;; adding more).
61 ;; - As a special case, if the "BEAMER_env" property is set to either
62 ;; "appendix", "note", "noteNH" or "againframe", the headline will
63 ;; become, respectively, an appendix, a note (within frame or
64 ;; between frame, depending on its level), a note with its title
65 ;; ignored or an againframe command. In the latter case,
66 ;; a "BEAMER_ref" property is mandatory in order to refer to the
67 ;; frame being resumed, and contents are ignored.
69 ;; Also, a headline with an "ignoreheading" environment will have
70 ;; its contents only inserted in the output. This special value is
71 ;; useful to have data between frames, or to properly close
72 ;; a "column" environment.
74 ;; Along with "BEAMER_env", headlines also support the "BEAMER_act"
75 ;; and "BEAMER_opt" properties. The former is translated as an
76 ;; overlay/action specification (or a default overlay specification
77 ;; when enclosed within square brackets) whereas the latter specifies
78 ;; options for the current frame ("fragile" option is added
79 ;; automatically, though).
81 ;; Moreover, headlines handle the "BEAMER_col" property. Its value
82 ;; should be a decimal number representing the width of the column as
83 ;; a fraction of the total text width. If the headline has no
84 ;; specific environment, its title will be ignored and its contents
85 ;; will fill the column created. Otherwise, the block will fill the
86 ;; whole column and the title will be preserved. Two contiguous
87 ;; headlines with a non-nil "BEAMER_col" value share the same
88 ;; "columns" LaTeX environment. It will end before the next headline
89 ;; without such a property. This environment is generated
90 ;; automatically. Although, it can also be explicitly created, with
91 ;; a special "columns" value for "BEAMER_env" property (if it needs to
92 ;; be set up with some specific options, for example).
94 ;; Every plain list has support for `:environment', `:overlay' and
95 ;; `:options' attributes (through ATTR_BEAMER affiliated keyword).
96 ;; The first one allows to use a different environment, the second
97 ;; sets overlay specifications and the last one inserts optional
98 ;; arguments in current list environment.
100 ;; Table of contents generated from "toc:t" option item are wrapped
101 ;; within a "frame" environment. Those generated from a TOC keyword
102 ;; aren't. TOC keywords accept options enclosed within square
103 ;; brackets (e.g. #+TOC: headlines [currentsection]).
105 ;; Eventually, an export snippet with a value enclosed within angular
106 ;; brackets put at the beginning of an element or object whose type is
107 ;; among `bold', `item', `link', `radio-target' and `target' will
108 ;; control its overlay specifications.
110 ;; On the minor mode side, `org-beamer-select-environment' (bound by
111 ;; default to "C-c C-b") and `org-beamer-insert-options-template' are
112 ;; the two entry points.
114 ;;; Code:
116 (eval-when-compile (require 'cl))
117 (require 'ox-latex)
121 ;;; User-Configurable Variables
123 (defgroup org-export-beamer nil
124 "Options specific for using the beamer class in LaTeX export."
125 :tag "Org Beamer"
126 :group 'org-export
127 :version "24.2")
129 (defcustom org-beamer-frame-level 1
130 "The level at which headlines become frames.
132 Headlines at a lower level will be translated into a sectioning
133 structure. At a higher level, they will be translated into
134 blocks.
136 If a headline with a \"BEAMER_env\" property set to \"frame\" is
137 found within a tree, its level locally overrides this number.
139 This variable has no effect on headlines with the \"BEAMER_env\"
140 property set to either \"ignoreheading\", \"appendix\", or
141 \"note\", which will respectively, be invisible, become an
142 appendix or a note.
144 This integer is relative to the minimal level of a headline
145 within the parse tree, defined as 1."
146 :group 'org-export-beamer
147 :type 'integer)
149 (defcustom org-beamer-frame-default-options ""
150 "Default options string to use for frames.
151 For example, it could be set to \"allowframebreaks\"."
152 :group 'org-export-beamer
153 :type '(string :tag "[options]"))
155 (defcustom org-beamer-column-view-format
156 "%45ITEM %10BEAMER_env(Env) %10BEAMER_act(Act) %4BEAMER_col(Col) %8BEAMER_opt(Opt)"
157 "Column view format that should be used to fill the template."
158 :group 'org-export-beamer
159 :version "24.4"
160 :package-version '(Org . "8.0")
161 :type '(choice
162 (const :tag "Do not insert Beamer column view format" nil)
163 (string :tag "Beamer column view format")))
165 (defcustom org-beamer-theme "default"
166 "Default theme used in Beamer presentations."
167 :group 'org-export-beamer
168 :version "24.4"
169 :package-version '(Org . "8.0")
170 :type '(choice
171 (const :tag "Do not insert a Beamer theme" nil)
172 (string :tag "Beamer theme")))
174 (defcustom org-beamer-environments-extra nil
175 "Environments triggered by tags in Beamer export.
176 Each entry has 4 elements:
178 name Name of the environment
179 key Selection key for `org-beamer-select-environment'
180 open The opening template for the environment, with the following escapes
181 %a the action/overlay specification
182 %A the default action/overlay specification
183 %o the options argument of the template
184 %h the headline text
185 %H if there is headline text, that text in {} braces
186 %U if there is headline text, that text in [] brackets
187 close The closing string of the environment."
188 :group 'org-export-beamer
189 :version "24.4"
190 :package-version '(Org . "8.0")
191 :type '(repeat
192 (list
193 (string :tag "Environment")
194 (string :tag "Selection key")
195 (string :tag "Begin")
196 (string :tag "End"))))
198 (defcustom org-beamer-outline-frame-title "Outline"
199 "Default title of a frame containing an outline."
200 :group 'org-export-beamer
201 :type '(string :tag "Outline frame title"))
203 (defcustom org-beamer-outline-frame-options ""
204 "Outline frame options appended after \\begin{frame}.
205 You might want to put e.g. \"allowframebreaks=0.9\" here."
206 :group 'org-export-beamer
207 :type '(string :tag "Outline frame options"))
211 ;;; Internal Variables
213 (defconst org-beamer-column-widths
214 "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
215 "The column widths that should be installed as allowed property values.")
217 (defconst org-beamer-environments-special
218 '(("againframe" "A")
219 ("appendix" "x")
220 ("column" "c")
221 ("columns" "C")
222 ("frame" "f")
223 ("fullframe" "F")
224 ("ignoreheading" "i")
225 ("note" "n")
226 ("noteNH" "N"))
227 "Alist of environments treated in a special way by the back-end.
228 Keys are environment names, as strings, values are bindings used
229 in `org-beamer-select-environment'. Environments listed here,
230 along with their binding, are hard coded and cannot be modified
231 through `org-beamer-environments-extra' variable.")
233 (defconst org-beamer-environments-default
234 '(("block" "b" "\\begin{block}%a{%h}" "\\end{block}")
235 ("alertblock" "a" "\\begin{alertblock}%a{%h}" "\\end{alertblock}")
236 ("verse" "v" "\\begin{verse}%a %% %h" "\\end{verse}")
237 ("quotation" "q" "\\begin{quotation}%a %% %h" "\\end{quotation}")
238 ("quote" "Q" "\\begin{quote}%a %% %h" "\\end{quote}")
239 ("structureenv" "s" "\\begin{structureenv}%a %% %h" "\\end{structureenv}")
240 ("theorem" "t" "\\begin{theorem}%a%U" "\\end{theorem}")
241 ("definition" "d" "\\begin{definition}%a%U" "\\end{definition}")
242 ("example" "e" "\\begin{example}%a%U" "\\end{example}")
243 ("exampleblock" "E" "\\begin{exampleblock}%a{%h}" "\\end{exampleblock}")
244 ("proof" "p" "\\begin{proof}%a%U" "\\end{proof}")
245 ("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}" "\\end{beamercolorbox}"))
246 "Environments triggered by properties in Beamer export.
247 These are the defaults - for user definitions, see
248 `org-beamer-environments-extra'.")
250 (defconst org-beamer-verbatim-elements
251 '(code example-block fixed-width inline-src-block src-block verbatim)
252 "List of element or object types producing verbatim text.
253 This is used internally to determine when a frame should have the
254 \"fragile\" option.")
258 ;;; Internal functions
260 (defun org-beamer--normalize-argument (argument type)
261 "Return ARGUMENT string with proper boundaries.
263 TYPE is a symbol among the following:
264 `action' Return ARGUMENT within angular brackets.
265 `defaction' Return ARGUMENT within both square and angular brackets.
266 `option' Return ARGUMENT within square brackets."
267 (if (not (string-match "\\S-" argument)) ""
268 (case type
269 (action (if (string-match "\\`<.*>\\'" argument) argument
270 (format "<%s>" argument)))
271 (defaction (cond
272 ((string-match "\\`\\[<.*>\\]\\'" argument) argument)
273 ((string-match "\\`<.*>\\'" argument)
274 (format "[%s]" argument))
275 ((string-match "\\`\\[\\(.*\\)\\]\\'" argument)
276 (format "[<%s>]" (match-string 1 argument)))
277 (t (format "[<%s>]" argument))))
278 (option (if (string-match "\\`\\[.*\\]\\'" argument) argument
279 (format "[%s]" argument)))
280 (otherwise argument))))
282 (defun org-beamer--element-has-overlay-p (element)
283 "Non-nil when ELEMENT has an overlay specified.
284 An element has an overlay specification when it starts with an
285 `beamer' export-snippet whose value is between angular brackets.
286 Return overlay specification, as a string, or nil."
287 (let ((first-object (car (org-element-contents element))))
288 (when (eq (org-element-type first-object) 'export-snippet)
289 (let ((value (org-element-property :value first-object)))
290 (and (string-match "\\`<.*>\\'" value) value)))))
294 ;;; Define Back-End
296 (org-export-define-derived-backend beamer latex
297 :export-block "BEAMER"
298 :menu-entry
299 (?l 1
300 ((?B "As LaTeX buffer (Beamer)" org-beamer-export-as-latex)
301 (?b "As LaTeX file (Beamer)" org-beamer-export-to-latex)
302 (?P "As PDF file (Beamer)" org-beamer-export-to-pdf)
303 (?O "As PDF file and open (Beamer)"
304 (lambda (a s v b)
305 (if a (org-beamer-export-to-pdf t s v b)
306 (org-open-file (org-beamer-export-to-pdf nil s v b)))))))
307 :options-alist
308 ((:beamer-theme "BEAMER_THEME" nil org-beamer-theme)
309 (:beamer-color-theme "BEAMER_COLOR_THEME" nil nil t)
310 (:beamer-font-theme "BEAMER_FONT_THEME" nil nil t)
311 (:beamer-inner-theme "BEAMER_INNER_THEME" nil nil t)
312 (:beamer-outer-theme "BEAMER_OUTER_THEME" nil nil t)
313 (:beamer-header-extra "BEAMER_HEADER" nil nil newline)
314 (:headline-levels nil "H" org-beamer-frame-level))
315 :translate-alist ((bold . org-beamer-bold)
316 (export-block . org-beamer-export-block)
317 (export-snippet . org-beamer-export-snippet)
318 (headline . org-beamer-headline)
319 (item . org-beamer-item)
320 (keyword . org-beamer-keyword)
321 (link . org-beamer-link)
322 (plain-list . org-beamer-plain-list)
323 (radio-target . org-beamer-radio-target)
324 (target . org-beamer-target)
325 (template . org-beamer-template)))
329 ;;; Transcode Functions
331 ;;;; Bold
333 (defun org-beamer-bold (bold contents info)
334 "Transcode BLOCK object into Beamer code.
335 CONTENTS is the text being bold. INFO is a plist used as
336 a communication channel."
337 (format "\\alert%s{%s}"
338 (or (org-beamer--element-has-overlay-p bold) "")
339 contents))
342 ;;;; Export Block
344 (defun org-beamer-export-block (export-block contents info)
345 "Transcode an EXPORT-BLOCK element into Beamer code.
346 CONTENTS is nil. INFO is a plist used as a communication
347 channel."
348 (when (member (org-element-property :type export-block) '("BEAMER" "LATEX"))
349 (org-remove-indentation (org-element-property :value export-block))))
352 ;;;; Export Snippet
354 (defun org-beamer-export-snippet (export-snippet contents info)
355 "Transcode an EXPORT-SNIPPET object into Beamer code.
356 CONTENTS is nil. INFO is a plist used as a communication
357 channel."
358 (let ((backend (org-export-snippet-backend export-snippet))
359 (value (org-element-property :value export-snippet)))
360 ;; Only "latex" and "beamer" snippets are retained.
361 (cond ((eq backend 'latex) value)
362 ;; Ignore "beamer" snippets specifying overlays.
363 ((and (eq backend 'beamer)
364 (or (org-export-get-previous-element export-snippet info)
365 (not (string-match "\\`<.*>\\'" value))))
366 value))))
369 ;;;; Headline
371 ;; The main function to translate a headline is
372 ;; `org-beamer-headline'.
374 ;; Depending on the level at which a headline is considered as
375 ;; a frame (given by `org-beamer--frame-level'), the headline is
376 ;; either a section (`org-beamer--format-section'), a frame
377 ;; (`org-beamer--format-frame') or a block
378 ;; (`org-beamer--format-block').
380 ;; `org-beamer-headline' also takes care of special environments
381 ;; like "ignoreheading", "note", "noteNH", "appendix" and
382 ;; "againframe".
384 (defun org-beamer--get-label (headline info)
385 "Return label for HEADLINE, as a string.
387 INFO is a plist used as a communication channel.
389 The value is either the label specified in \"BEAMER_opt\"
390 property, or a fallback value built from headline's number. This
391 function assumes HEADLINE will be treated as a frame."
392 (let ((opt (org-element-property :BEAMER_OPT headline)))
393 (if (and (org-string-nw-p opt)
394 (string-match "\\(?:^\\|,\\)label=\\(.*?\\)\\(?:$\\|,\\)" opt))
395 (match-string 1 opt)
396 (format "sec-%s"
397 (mapconcat 'number-to-string
398 (org-export-get-headline-number headline info)
399 "-")))))
401 (defun org-beamer--frame-level (headline info)
402 "Return frame level in subtree containing HEADLINE.
403 INFO is a plist used as a communication channel."
405 ;; 1. Look for "frame" environment in parents, starting from the
406 ;; farthest.
407 (catch 'exit
408 (mapc (lambda (parent)
409 (let ((env (org-element-property :BEAMER_ENV parent)))
410 (when (and env (member (downcase env) '("frame" "fullframe")))
411 (throw 'exit (org-export-get-relative-level parent info)))))
412 (nreverse (org-export-get-genealogy headline)))
413 nil)
414 ;; 2. Look for "frame" environment in HEADLINE.
415 (let ((env (org-element-property :BEAMER_ENV headline)))
416 (and env (member (downcase env) '("frame" "fullframe"))
417 (org-export-get-relative-level headline info)))
418 ;; 3. Look for "frame" environment in sub-tree.
419 (org-element-map headline 'headline
420 (lambda (hl)
421 (let ((env (org-element-property :BEAMER_ENV hl)))
422 (when (and env (member (downcase env) '("frame" "fullframe")))
423 (org-export-get-relative-level hl info))))
424 info 'first-match)
425 ;; 4. No "frame" environment in tree: use default value.
426 (plist-get info :headline-levels)))
428 (defun org-beamer--format-section (headline contents info)
429 "Format HEADLINE as a sectioning part.
430 CONTENTS holds the contents of the headline. INFO is a plist
431 used as a communication channel."
432 ;; Use `latex' back-end output, inserting overlay specifications
433 ;; if possible.
434 (let ((latex-headline (org-export-with-backend 'latex headline contents info))
435 (mode-specs (org-element-property :BEAMER_ACT headline)))
436 (if (and mode-specs
437 (string-match "\\`\\\\\\(.*?\\)\\(?:\\*\\|\\[.*\\]\\)?{"
438 latex-headline))
439 (replace-match (concat (match-string 1 latex-headline)
440 (format "<%s>" mode-specs))
441 nil nil latex-headline 1)
442 latex-headline)))
444 (defun org-beamer--format-frame (headline contents info)
445 "Format HEADLINE as a frame.
446 CONTENTS holds the contents of the headline. INFO is a plist
447 used as a communication channel."
448 (let ((fragilep
449 ;; FRAGILEP is non-nil when HEADLINE contains an element
450 ;; among `org-beamer-verbatim-elements'.
451 (org-element-map headline org-beamer-verbatim-elements 'identity
452 info 'first-match)))
453 (concat "\\begin{frame}"
454 ;; Overlay specification, if any. When surrounded by
455 ;; square brackets, consider it as a default
456 ;; specification.
457 (let ((action (org-element-property :BEAMER_ACT headline)))
458 (cond
459 ((not action) "")
460 ((string-match "\\`\\[.*\\]\\'" action )
461 (org-beamer--normalize-argument action 'defaction))
462 (t (org-beamer--normalize-argument action 'action))))
463 ;; Options, if any.
464 (let* ((beamer-opt (org-element-property :BEAMER_OPT headline))
465 (options
466 ;; Collect options from default value and headline's
467 ;; properties. Also add a label for links.
468 (append
469 (org-split-string org-beamer-frame-default-options ",")
470 (and beamer-opt
471 (org-split-string
472 ;; Remove square brackets if user provided
473 ;; them.
474 (and (string-match "^\\[?\\(.*\\)\\]?$" beamer-opt)
475 (match-string 1 beamer-opt))
476 ","))
477 ;; Provide an automatic label for the frame
478 ;; unless the user specified one.
479 (unless (and beamer-opt
480 (string-match "\\(^\\|,\\)label=" beamer-opt))
481 (list
482 (format "label=%s"
483 (org-beamer--get-label headline info)))))))
484 ;; Change options list into a string.
485 (org-beamer--normalize-argument
486 (mapconcat
487 'identity
488 (if (or (not fragilep) (member "fragile" options)) options
489 (cons "fragile" options))
490 ",")
491 'option))
492 ;; Title.
493 (let ((env (org-element-property :BEAMER_ENV headline)))
494 (format "{%s}"
495 (if (and env (equal (downcase env) "fullframe")) ""
496 (org-export-data
497 (org-element-property :title headline) info))))
498 "\n"
499 ;; The following workaround is required in fragile frames
500 ;; as Beamer will append "\par" to the beginning of the
501 ;; contents. So we need to make sure the command is
502 ;; separated from the contents by at least one space. If
503 ;; it isn't, it will create "\parfirst-word" command and
504 ;; remove the first word from the contents in the PDF
505 ;; output.
506 (if (not fragilep) contents
507 (replace-regexp-in-string "\\`\n*" "\\& " contents))
508 "\\end{frame}")))
510 (defun org-beamer--format-block (headline contents info)
511 "Format HEADLINE as a block.
512 CONTENTS holds the contents of the headline. INFO is a plist
513 used as a communication channel."
514 (let* ((column-width (org-element-property :BEAMER_COL headline))
515 ;; ENVIRONMENT defaults to "block" if none is specified and
516 ;; there is no column specification. If there is a column
517 ;; specified but still no explicit environment, ENVIRONMENT
518 ;; is "column".
519 (environment (let ((env (org-element-property :BEAMER_ENV headline)))
520 (cond
521 ;; "block" is the fallback environment.
522 ((and (not env) (not column-width)) "block")
523 ;; "column" only.
524 ((not env) "column")
525 ;; Use specified environment.
526 (t (downcase env)))))
527 (env-format (unless (member environment '("column" "columns"))
528 (assoc environment
529 (append org-beamer-environments-special
530 org-beamer-environments-extra
531 org-beamer-environments-default))))
532 (title (org-export-data (org-element-property :title headline) info))
533 (options (let ((options (org-element-property :BEAMER_OPT headline)))
534 (if (not options) ""
535 (org-beamer--normalize-argument options 'option))))
536 ;; Start a "columns" environment when explicitly requested or
537 ;; when there is no previous headline or the previous
538 ;; headline do not have a BEAMER_column property.
539 (parent-env (org-element-property
540 :BEAMER_ENV (org-export-get-parent-headline headline)))
541 (start-columns-p
542 (or (equal environment "columns")
543 (and column-width
544 (not (and parent-env
545 (equal (downcase parent-env) "columns")))
546 (or (org-export-first-sibling-p headline info)
547 (not (org-element-property
548 :BEAMER_COL
549 (org-export-get-previous-element
550 headline info)))))))
551 ;; End the "columns" environment when explicitly requested or
552 ;; when there is no next headline or the next headline do not
553 ;; have a BEAMER_column property.
554 (end-columns-p
555 (or (equal environment "columns")
556 (and column-width
557 (not (and parent-env
558 (equal (downcase parent-env) "columns")))
559 (or (org-export-last-sibling-p headline info)
560 (not (org-element-property
561 :BEAMER_COL
562 (org-export-get-next-element headline info))))))))
563 (concat
564 (when start-columns-p
565 ;; Column can accept options only when the environment is
566 ;; explicitly defined.
567 (if (not (equal environment "columns")) "\\begin{columns}\n"
568 (format "\\begin{columns}%s\n" options)))
569 (when column-width
570 (format "\\begin{column}%s{%s}\n"
571 ;; One can specify placement for column only when
572 ;; HEADLINE stands for a column on its own.
573 (if (equal environment "column") options "")
574 (format "%s\\textwidth" column-width)))
575 ;; Block's opening string.
576 (when env-format
577 (concat
578 (org-fill-template
579 (nth 2 env-format)
580 (nconc
581 ;; If BEAMER_act property has its value enclosed in square
582 ;; brackets, it is a default overlay specification and
583 ;; overlay specification is empty. Otherwise, it is an
584 ;; overlay specification and the default one is nil.
585 (let ((action (org-element-property :BEAMER_ACT headline)))
586 (cond
587 ((not action) (list (cons "a" "") (cons "A" "")))
588 ((string-match "\\`\\[.*\\]\\'" action)
589 (list
590 (cons "A" (org-beamer--normalize-argument action 'defaction))
591 (cons "a" "")))
593 (list (cons "a" (org-beamer--normalize-argument action 'action))
594 (cons "A" "")))))
595 (list (cons "o" options)
596 (cons "h" title)
597 (cons "H" (if (equal title "") "" (format "{%s}" title)))
598 (cons "U" (if (equal title "") "" (format "[%s]" title))))))
599 "\n"))
600 contents
601 ;; Block's closing string.
602 (when environment (concat (nth 3 env-format) "\n"))
603 (when column-width "\\end{column}\n")
604 (when end-columns-p "\\end{columns}"))))
606 (defun org-beamer-headline (headline contents info)
607 "Transcode HEADLINE element into Beamer code.
608 CONTENTS is the contents of the headline. INFO is a plist used
609 as a communication channel."
610 (unless (org-element-property :footnote-section-p headline)
611 (let ((level (org-export-get-relative-level headline info))
612 (frame-level (org-beamer--frame-level headline info))
613 (environment (let ((env (org-element-property :BEAMER_ENV headline)))
614 (if (stringp env) (downcase env) "block"))))
615 (cond
616 ;; Case 1: Resume frame specified by "BEAMER_ref" property.
617 ((equal environment "againframe")
618 (let ((ref (org-element-property :BEAMER_REF headline)))
619 ;; Reference to frame being resumed is mandatory. Ignore
620 ;; the whole headline if it isn't provided.
621 (when (org-string-nw-p ref)
622 (concat "\\againframe"
623 ;; Overlay specification.
624 (let ((overlay (org-element-property :BEAMER_ACT headline)))
625 (when overlay
626 (org-beamer--normalize-argument
627 overlay
628 (if (string-match "^\\[.*\\]$" overlay) 'defaction
629 'action))))
630 ;; Options.
631 (let ((options (org-element-property :BEAMER_OPT headline)))
632 (when options
633 (org-beamer--normalize-argument options 'option)))
634 ;; Resolve reference provided by "BEAMER_ref"
635 ;; property. This is done by building a minimal fake
636 ;; link and calling the appropriate resolve function,
637 ;; depending on the reference syntax.
638 (let* ((type
639 (progn
640 (string-match "^\\(id:\\|#\\|\\*\\)?\\(.*\\)" ref)
641 (cond
642 ((or (not (match-string 1 ref))
643 (equal (match-string 1 ref) "*")) 'fuzzy)
644 ((equal (match-string 1 ref) "id:") 'id)
645 (t 'custom-id))))
646 (link (list 'link (list :path (match-string 2 ref))))
647 (target (if (eq type 'fuzzy)
648 (org-export-resolve-fuzzy-link link info)
649 (org-export-resolve-id-link link info))))
650 ;; Now use user-defined label provided in TARGET
651 ;; headline, or fallback to standard one.
652 (format "{%s}" (org-beamer--get-label target info)))))))
653 ;; Case 2: Creation of an appendix is requested.
654 ((equal environment "appendix")
655 (concat "\\appendix"
656 (org-element-property :BEAMER_ACT headline)
657 "\n"
658 (make-string (org-element-property :pre-blank headline) ?\n)
659 contents))
660 ;; Case 3: Ignore heading.
661 ((equal environment "ignoreheading")
662 (concat (make-string (org-element-property :pre-blank headline) ?\n)
663 contents))
664 ;; Case 4: HEADLINE is a note.
665 ((member environment '("note" "noteNH"))
666 (format "\\note{%s}"
667 (concat (and (equal environment "note")
668 (concat
669 (org-export-data
670 (org-element-property :title headline) info)
671 "\n"))
672 (org-trim contents))))
673 ;; Case 5: HEADLINE is a frame.
674 ((= level frame-level)
675 (org-beamer--format-frame headline contents info))
676 ;; Case 6: Regular section, extracted from
677 ;; `org-latex-classes'.
678 ((< level frame-level)
679 (org-beamer--format-section headline contents info))
680 ;; Case 7: Otherwise, HEADLINE is a block.
681 (t (org-beamer--format-block headline contents info))))))
684 ;;;; Item
686 (defun org-beamer-item (item contents info)
687 "Transcode an ITEM element into Beamer code.
688 CONTENTS holds the contents of the item. INFO is a plist holding
689 contextual information."
690 (let ((action (let ((first-element (car (org-element-contents item))))
691 (and (eq (org-element-type first-element) 'paragraph)
692 (org-beamer--element-has-overlay-p first-element))))
693 (output (org-export-with-backend 'latex item contents info)))
694 (if (not action) output
695 ;; If the item starts with a paragraph and that paragraph starts
696 ;; with an export snippet specifying an overlay, insert it after
697 ;; \item command.
698 (replace-regexp-in-string "\\\\item" (concat "\\\\item" action) output))))
701 ;;;; Keyword
703 (defun org-beamer-keyword (keyword contents info)
704 "Transcode a KEYWORD element into Beamer code.
705 CONTENTS is nil. INFO is a plist used as a communication
706 channel."
707 (let ((key (org-element-property :key keyword))
708 (value (org-element-property :value keyword)))
709 ;; Handle specifically BEAMER and TOC (headlines only) keywords.
710 ;; Otherwise, fallback to `latex' back-end.
711 (cond
712 ((equal key "BEAMER") value)
713 ((and (equal key "TOC") (string-match "\\<headlines\\>" value))
714 (let ((depth (or (and (string-match "[0-9]+" value)
715 (string-to-number (match-string 0 value)))
716 (plist-get info :with-toc)))
717 (options (and (string-match "\\[.*?\\]" value)
718 (match-string 0 value))))
719 (concat
720 (when (wholenump depth) (format "\\setcounter{tocdepth}{%s}\n" depth))
721 "\\tableofcontents" options)))
722 (t (org-export-with-backend 'latex keyword contents info)))))
725 ;;;; Link
727 (defun org-beamer-link (link contents info)
728 "Transcode a LINK object into Beamer code.
729 CONTENTS is the description part of the link. INFO is a plist
730 used as a communication channel."
731 (let ((type (org-element-property :type link))
732 (path (org-element-property :path link)))
733 ;; Use \hyperlink command for all internal links.
734 (cond
735 ((equal type "radio")
736 (let ((destination (org-export-resolve-radio-link link info)))
737 (when destination
738 (format "\\hyperlink%s{%s}{%s}"
739 (or (org-beamer--element-has-overlay-p link) "")
740 (org-export-solidify-link-text path)
741 (org-export-data (org-element-contents destination) info)))))
742 ((and (member type '("custom-id" "fuzzy" "id"))
743 (let ((destination (if (string= type "fuzzy")
744 (org-export-resolve-fuzzy-link link info)
745 (org-export-resolve-id-link link info))))
746 (case (org-element-type destination)
747 (headline
748 (let ((label
749 (format "sec-%s"
750 (mapconcat
751 'number-to-string
752 (org-export-get-headline-number
753 destination info)
754 "-"))))
755 (if (and (plist-get info :section-numbers) (not contents))
756 (format "\\ref{%s}" label)
757 (format "\\hyperlink%s{%s}{%s}"
758 (or (org-beamer--element-has-overlay-p link) "")
759 label
760 contents))))
761 (target
762 (let ((path (org-export-solidify-link-text path)))
763 (if (not contents) (format "\\ref{%s}" path)
764 (format "\\hyperlink%s{%s}{%s}"
765 (or (org-beamer--element-has-overlay-p link) "")
766 path
767 contents))))))))
768 ;; Otherwise, use `latex' back-end.
769 (t (org-export-with-backend 'latex link contents info)))))
772 ;;;; Plain List
774 ;; Plain lists support `:environment', `:overlay' and `:options'
775 ;; attributes.
777 (defun org-beamer-plain-list (plain-list contents info)
778 "Transcode a PLAIN-LIST element into Beamer code.
779 CONTENTS is the contents of the list. INFO is a plist holding
780 contextual information."
781 (let* ((type (org-element-property :type plain-list))
782 (attributes (org-combine-plists
783 (org-export-read-attribute :attr_latex plain-list)
784 (org-export-read-attribute :attr_beamer plain-list)))
785 (latex-type (let ((env (plist-get attributes :environment)))
786 (cond (env (format "%s" env))
787 ((eq type 'ordered) "enumerate")
788 ((eq type 'descriptive) "description")
789 (t "itemize")))))
790 (org-latex--wrap-label
791 plain-list
792 (format "\\begin{%s}%s%s\n%s\\end{%s}"
793 latex-type
794 ;; Default overlay specification, if any.
795 (org-beamer--normalize-argument
796 (format "%s" (or (plist-get attributes :overlay) ""))
797 'defaction)
798 ;; Second optional argument depends on the list type.
799 (org-beamer--normalize-argument
800 (format "%s" (or (plist-get attributes :options) ""))
801 'option)
802 ;; Eventually insert contents and close environment.
803 contents
804 latex-type))))
807 ;;;; Radio Target
809 (defun org-beamer-radio-target (radio-target text info)
810 "Transcode a RADIO-TARGET object into Beamer code.
811 TEXT is the text of the target. INFO is a plist holding
812 contextual information."
813 (format "\\hypertarget%s{%s}{%s}"
814 (or (org-beamer--element-has-overlay-p radio-target) "")
815 (org-export-solidify-link-text
816 (org-element-property :value radio-target))
817 text))
820 ;;;; Target
822 (defun org-beamer-target (target contents info)
823 "Transcode a TARGET object into Beamer code.
824 CONTENTS is nil. INFO is a plist holding contextual
825 information."
826 (format "\\hypertarget{%s}{}"
827 (org-export-solidify-link-text (org-element-property :value target))))
830 ;;;; Template
832 ;; Template used is similar to the one used in `latex' back-end,
833 ;; excepted for the table of contents and Beamer themes.
835 (defun org-beamer-template (contents info)
836 "Return complete document string after Beamer conversion.
837 CONTENTS is the transcoded contents string. INFO is a plist
838 holding export options."
839 (let ((title (org-export-data (plist-get info :title) info)))
840 (concat
841 ;; 1. Time-stamp.
842 (and (plist-get info :time-stamp-file)
843 (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
844 ;; 2. Document class and packages.
845 (let ((class (plist-get info :latex-class))
846 (class-options (plist-get info :latex-class-options)))
847 (org-element-normalize-string
848 (let* ((header (nth 1 (assoc class org-latex-classes)))
849 (document-class-string
850 (and (stringp header)
851 (if (not class-options) header
852 (replace-regexp-in-string
853 "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
854 class-options header t nil 1)))))
855 (if (not document-class-string)
856 (user-error "Unknown LaTeX class `%s'" class)
857 (org-latex-guess-babel-language
858 (org-latex-guess-inputenc
859 (org-splice-latex-header
860 document-class-string
861 org-latex-default-packages-alist
862 org-latex-packages-alist nil
863 (concat (plist-get info :latex-header)
864 (plist-get info :latex-header-extra)
865 (plist-get info :beamer-header-extra))))
866 info)))))
867 ;; 3. Insert themes.
868 (let ((format-theme
869 (function
870 (lambda (prop command)
871 (let ((theme (plist-get info prop)))
872 (when theme
873 (concat command
874 (if (not (string-match "\\[.*\\]" theme))
875 (format "{%s}\n" theme)
876 (format "%s{%s}\n"
877 (match-string 0 theme)
878 (org-trim
879 (replace-match "" nil nil theme)))))))))))
880 (mapconcat (lambda (args) (apply format-theme args))
881 '((:beamer-theme "\\usetheme")
882 (:beamer-color-theme "\\usecolortheme")
883 (:beamer-font-theme "\\usefonttheme")
884 (:beamer-inner-theme "\\useinnertheme")
885 (:beamer-outer-theme "\\useoutertheme"))
886 ""))
887 ;; 4. Possibly limit depth for headline numbering.
888 (let ((sec-num (plist-get info :section-numbers)))
889 (when (integerp sec-num)
890 (format "\\setcounter{secnumdepth}{%d}\n" sec-num)))
891 ;; 5. Author.
892 (let ((author (and (plist-get info :with-author)
893 (let ((auth (plist-get info :author)))
894 (and auth (org-export-data auth info)))))
895 (email (and (plist-get info :with-email)
896 (org-export-data (plist-get info :email) info))))
897 (cond ((and author email (not (string= "" email)))
898 (format "\\author{%s\\thanks{%s}}\n" author email))
899 (author (format "\\author{%s}\n" author))
900 (t "\\author{}\n")))
901 ;; 6. Date.
902 (let ((date (and (plist-get info :with-date) (plist-get info :date))))
903 (format "\\date{%s}\n"
904 (cond ((not date) "")
905 ;; If `:date' consists in a single timestamp and
906 ;; `:date-format' is provided, apply it.
907 ((and (plist-get info :date-format)
908 (not (cdr date))
909 (eq (org-element-type (car date)) 'timestamp))
910 (org-timestamp-format
911 (car date) (plist-get info :date-format)))
912 (t (org-export-data date info)))))
913 ;; 7. Title
914 (format "\\title{%s}\n" title)
915 ;; 8. Hyperref options.
916 (when (plist-get info :latex-hyperref-p)
917 (format "\\hypersetup{\n pdfkeywords={%s},\n pdfsubject={%s},\n pdfcreator={%s}}\n"
918 (or (plist-get info :keywords) "")
919 (or (plist-get info :description) "")
920 (if (not (plist-get info :with-creator)) ""
921 (plist-get info :creator))))
922 ;; 9. Document start.
923 "\\begin{document}\n\n"
924 ;; 10. Title command.
925 (org-element-normalize-string
926 (cond ((string= "" title) nil)
927 ((not (stringp org-latex-title-command)) nil)
928 ((string-match "\\(?:[^%]\\|^\\)%s"
929 org-latex-title-command)
930 (format org-latex-title-command title))
931 (t org-latex-title-command)))
932 ;; 11. Table of contents.
933 (let ((depth (plist-get info :with-toc)))
934 (when depth
935 (concat
936 (format "\\begin{frame}%s{%s}\n"
937 (org-beamer--normalize-argument
938 org-beamer-outline-frame-options 'option)
939 org-beamer-outline-frame-title)
940 (when (wholenump depth)
941 (format "\\setcounter{tocdepth}{%d}\n" depth))
942 "\\tableofcontents\n"
943 "\\end{frame}\n\n")))
944 ;; 12. Document's body.
945 contents
946 ;; 13. Creator.
947 (let ((creator-info (plist-get info :with-creator)))
948 (cond
949 ((not creator-info) "")
950 ((eq creator-info 'comment)
951 (format "%% %s\n" (plist-get info :creator)))
952 (t (concat (plist-get info :creator) "\n"))))
953 ;; 14. Document end.
954 "\\end{document}")))
958 ;;; Minor Mode
961 (defvar org-beamer-mode-map (make-sparse-keymap)
962 "The keymap for `org-beamer-mode'.")
963 (define-key org-beamer-mode-map "\C-c\C-b" 'org-beamer-select-environment)
965 ;;;###autoload
966 (define-minor-mode org-beamer-mode
967 "Support for editing Beamer oriented Org mode files."
968 nil " Bm" 'org-beamer-mode-map)
970 (when (fboundp 'font-lock-add-keywords)
971 (font-lock-add-keywords
972 'org-mode
973 '((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
974 'prepend))
976 (defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
977 "The special face for beamer tags."
978 :group 'org-export-beamer)
980 (defun org-beamer-property-changed (property value)
981 "Track the BEAMER_env property with tags.
982 PROPERTY is the name of the modified property. VALUE is its new
983 value."
984 (cond
985 ((equal property "BEAMER_env")
986 (save-excursion
987 (org-back-to-heading t)
988 ;; Filter out Beamer-related tags and install environment tag.
989 (let ((tags (org-remove-if (lambda (x) (string-match "^B_" x))
990 (org-get-tags)))
991 (env-tag (and (org-string-nw-p value) (concat "B_" value))))
992 (org-set-tags-to (if env-tag (cons env-tag tags) tags))
993 (when env-tag (org-toggle-tag env-tag 'on)))))
994 ((equal property "BEAMER_col")
995 (org-toggle-tag "BMCOL" (if (org-string-nw-p value) 'on 'off)))))
997 (add-hook 'org-property-changed-functions 'org-beamer-property-changed)
999 (defun org-beamer-allowed-property-values (property)
1000 "Supply allowed values for PROPERTY."
1001 (cond
1002 ((and (equal property "BEAMER_env")
1003 (not (org-entry-get nil (concat property "_ALL") 'inherit)))
1004 ;; If no allowed values for BEAMER_env have been defined,
1005 ;; supply all defined environments
1006 (mapcar 'car (append org-beamer-environments-special
1007 org-beamer-environments-extra
1008 org-beamer-environments-default)))
1009 ((and (equal property "BEAMER_col")
1010 (not (org-entry-get nil (concat property "_ALL") 'inherit)))
1011 ;; If no allowed values for BEAMER_col have been defined,
1012 ;; supply some
1013 (org-split-string org-beamer-column-widths " "))))
1015 (add-hook 'org-property-allowed-value-functions
1016 'org-beamer-allowed-property-values)
1020 ;;; Commands
1022 ;;;###autoload
1023 (defun org-beamer-export-as-latex
1024 (&optional async subtreep visible-only body-only ext-plist)
1025 "Export current buffer as a Beamer buffer.
1027 If narrowing is active in the current buffer, only export its
1028 narrowed part.
1030 If a region is active, export that region.
1032 A non-nil optional argument ASYNC means the process should happen
1033 asynchronously. The resulting buffer should be accessible
1034 through the `org-export-stack' interface.
1036 When optional argument SUBTREEP is non-nil, export the sub-tree
1037 at point, extracting information from the headline properties
1038 first.
1040 When optional argument VISIBLE-ONLY is non-nil, don't export
1041 contents of hidden elements.
1043 When optional argument BODY-ONLY is non-nil, only write code
1044 between \"\\begin{document}\" and \"\\end{document}\".
1046 EXT-PLIST, when provided, is a property list with external
1047 parameters overriding Org default settings, but still inferior to
1048 file-local settings.
1050 Export is done in a buffer named \"*Org BEAMER Export*\", which
1051 will be displayed when `org-export-show-temporary-export-buffer'
1052 is non-nil."
1053 (interactive)
1054 (if async
1055 (org-export-async-start
1056 (lambda (output)
1057 (with-current-buffer (get-buffer-create "*Org BEAMER Export*")
1058 (erase-buffer)
1059 (insert output)
1060 (goto-char (point-min))
1061 (LaTeX-mode)
1062 (org-export-add-to-stack (current-buffer) 'beamer)))
1063 `(org-export-as 'beamer ,subtreep ,visible-only ,body-only
1064 ',ext-plist))
1065 (let ((outbuf (org-export-to-buffer
1066 'beamer "*Org BEAMER Export*"
1067 subtreep visible-only body-only ext-plist)))
1068 (with-current-buffer outbuf (LaTeX-mode))
1069 (when org-export-show-temporary-export-buffer
1070 (switch-to-buffer-other-window outbuf)))))
1072 ;;;###autoload
1073 (defun org-beamer-export-to-latex
1074 (&optional async subtreep visible-only body-only ext-plist)
1075 "Export current buffer as a Beamer presentation (tex).
1077 If narrowing is active in the current buffer, only export its
1078 narrowed part.
1080 If a region is active, export that region.
1082 A non-nil optional argument ASYNC means the process should happen
1083 asynchronously. The resulting file should be accessible through
1084 the `org-export-stack' interface.
1086 When optional argument SUBTREEP is non-nil, export the sub-tree
1087 at point, extracting information from the headline properties
1088 first.
1090 When optional argument VISIBLE-ONLY is non-nil, don't export
1091 contents of hidden elements.
1093 When optional argument BODY-ONLY is non-nil, only write code
1094 between \"\\begin{document}\" and \"\\end{document}\".
1096 EXT-PLIST, when provided, is a property list with external
1097 parameters overriding Org default settings, but still inferior to
1098 file-local settings.
1100 Return output file's name."
1101 (interactive)
1102 (let ((outfile (org-export-output-file-name ".tex" subtreep)))
1103 (if async
1104 (org-export-async-start
1105 (lambda (f) (org-export-add-to-stack f 'beamer))
1106 `(expand-file-name
1107 (org-export-to-file
1108 'beamer ,outfile ,subtreep ,visible-only ,body-only
1109 ',ext-plist)))
1110 (org-export-to-file
1111 'beamer outfile subtreep visible-only body-only ext-plist))))
1113 ;;;###autoload
1114 (defun org-beamer-export-to-pdf
1115 (&optional async subtreep visible-only body-only ext-plist)
1116 "Export current buffer as a Beamer presentation (PDF).
1118 If narrowing is active in the current buffer, only export its
1119 narrowed part.
1121 If a region is active, export that region.
1123 A non-nil optional argument ASYNC means the process should happen
1124 asynchronously. The resulting file should be accessible through
1125 the `org-export-stack' interface.
1127 When optional argument SUBTREEP is non-nil, export the sub-tree
1128 at point, extracting information from the headline properties
1129 first.
1131 When optional argument VISIBLE-ONLY is non-nil, don't export
1132 contents of hidden elements.
1134 When optional argument BODY-ONLY is non-nil, only write code
1135 between \"\\begin{document}\" and \"\\end{document}\".
1137 EXT-PLIST, when provided, is a property list with external
1138 parameters overriding Org default settings, but still inferior to
1139 file-local settings.
1141 Return PDF file's name."
1142 (interactive)
1143 (if async
1144 (let ((outfile (org-export-output-file-name ".tex" subtreep)))
1145 (org-export-async-start
1146 (lambda (f) (org-export-add-to-stack f 'beamer))
1147 `(expand-file-name
1148 (org-latex-compile
1149 (org-export-to-file
1150 'beamer ,outfile ,subtreep ,visible-only ,body-only
1151 ',ext-plist)))))
1152 (org-latex-compile
1153 (org-beamer-export-to-latex
1154 nil subtreep visible-only body-only ext-plist))))
1156 ;;;###autoload
1157 (defun org-beamer-select-environment ()
1158 "Select the environment to be used by beamer for this entry.
1159 While this uses (for convenience) a tag selection interface, the
1160 result of this command will be that the BEAMER_env *property* of
1161 the entry is set.
1163 In addition to this, the command will also set a tag as a visual
1164 aid, but the tag does not have any semantic meaning."
1165 (interactive)
1166 ;; Make sure `org-beamer-environments-special' has a higher
1167 ;; priority than `org-beamer-environments-extra'.
1168 (let* ((envs (append org-beamer-environments-special
1169 org-beamer-environments-extra
1170 org-beamer-environments-default))
1171 (org-tag-alist
1172 (append '((:startgroup))
1173 (mapcar (lambda (e) (cons (concat "B_" (car e))
1174 (string-to-char (nth 1 e))))
1175 envs)
1176 '((:endgroup))
1177 '(("BMCOL" . ?|))))
1178 (org-fast-tag-selection-single-key t))
1179 (org-set-tags)
1180 (let ((tags (or (ignore-errors (org-get-tags-string)) "")))
1181 (cond
1182 ;; For a column, automatically ask for its width.
1183 ((eq org-last-tag-selection-key ?|)
1184 (if (string-match ":BMCOL:" tags)
1185 (org-set-property "BEAMER_col" (read-string "Column width: "))
1186 (org-delete-property "BEAMER_col")))
1187 ;; For an "againframe" section, automatically ask for reference
1188 ;; to resumed frame and overlay specifications.
1189 ((eq org-last-tag-selection-key ?A)
1190 (if (equal (org-entry-get nil "BEAMER_env") "againframe")
1191 (progn (org-entry-delete nil "BEAMER_env")
1192 (org-entry-delete nil "BEAMER_ref")
1193 (org-entry-delete nil "BEAMER_act"))
1194 (org-entry-put nil "BEAMER_env" "againframe")
1195 (org-set-property
1196 "BEAMER_ref"
1197 (read-string "Frame reference (*Title, #custom-id, id:...): "))
1198 (org-set-property "BEAMER_act"
1199 (read-string "Overlay specification: "))))
1200 ((string-match (concat ":B_\\(" (mapconcat 'car envs "\\|") "\\):") tags)
1201 (org-entry-put nil "BEAMER_env" (match-string 1 tags)))
1202 (t (org-entry-delete nil "BEAMER_env"))))))
1204 ;;;###autoload
1205 (defun org-beamer-insert-options-template (&optional kind)
1206 "Insert a settings template, to make sure users do this right."
1207 (interactive (progn
1208 (message "Current [s]ubtree or [g]lobal?")
1209 (if (eq (read-char-exclusive) ?g) (list 'global)
1210 (list 'subtree))))
1211 (if (eq kind 'subtree)
1212 (progn
1213 (org-back-to-heading t)
1214 (org-reveal)
1215 (org-entry-put nil "EXPORT_LaTeX_CLASS" "beamer")
1216 (org-entry-put nil "EXPORT_LaTeX_CLASS_OPTIONS" "[presentation]")
1217 (org-entry-put nil "EXPORT_FILE_NAME" "presentation.pdf")
1218 (when org-beamer-column-view-format
1219 (org-entry-put nil "COLUMNS" org-beamer-column-view-format))
1220 (org-entry-put nil "BEAMER_col_ALL" org-beamer-column-widths))
1221 (insert "#+LaTeX_CLASS: beamer\n")
1222 (insert "#+LaTeX_CLASS_OPTIONS: [presentation]\n")
1223 (when org-beamer-theme (insert "#+BEAMER_THEME: " org-beamer-theme "\n"))
1224 (when org-beamer-column-view-format
1225 (insert "#+COLUMNS: " org-beamer-column-view-format "\n"))
1226 (insert "#+PROPERTY: BEAMER_col_ALL " org-beamer-column-widths "\n")))
1228 ;;;###autoload
1229 (defun org-beamer-publish-to-latex (plist filename pub-dir)
1230 "Publish an Org file to a Beamer presentation (LaTeX).
1232 FILENAME is the filename of the Org file to be published. PLIST
1233 is the property list for the given project. PUB-DIR is the
1234 publishing directory.
1236 Return output file name."
1237 (org-publish-org-to 'beamer filename ".tex" plist pub-dir))
1239 ;;;###autoload
1240 (defun org-beamer-publish-to-pdf (plist filename pub-dir)
1241 "Publish an Org file to a Beamer presentation (PDF, via LaTeX).
1243 FILENAME is the filename of the Org file to be published. PLIST
1244 is the property list for the given project. PUB-DIR is the
1245 publishing directory.
1247 Return output file name."
1248 ;; Unlike to `org-beamer-publish-to-latex', PDF file is generated in
1249 ;; working directory and then moved to publishing directory.
1250 (org-publish-attachment
1251 plist
1252 (org-latex-compile (org-publish-org-to 'beamer filename ".tex" plist))
1253 pub-dir))
1256 (provide 'ox-beamer)
1258 ;; Local variables:
1259 ;; generated-autoload-file: "org-loaddefs.el"
1260 ;; End:
1262 ;;; ox-beamer.el ends here