org-element: Parse warning delays in timestamps
[org-mode.git] / lisp / ox-beamer.el
blob74d99edce7b5cac6c7e57000793e94c0a2d0e6a9
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)
119 ;; Install a default set-up for Beamer export.
120 (unless (assoc "beamer" org-latex-classes)
121 (add-to-list 'org-latex-classes
122 '("beamer"
123 "\\documentclass[presentation]{beamer}
124 \[DEFAULT-PACKAGES]
125 \[PACKAGES]
126 \[EXTRA]"
127 ("\\section{%s}" . "\\section*{%s}")
128 ("\\subsection{%s}" . "\\subsection*{%s}")
129 ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
133 ;;; User-Configurable Variables
135 (defgroup org-export-beamer nil
136 "Options specific for using the beamer class in LaTeX export."
137 :tag "Org Beamer"
138 :group 'org-export
139 :version "24.2")
141 (defcustom org-beamer-frame-level 1
142 "The level at which headlines become frames.
144 Headlines at a lower level will be translated into a sectioning
145 structure. At a higher level, they will be translated into
146 blocks.
148 If a headline with a \"BEAMER_env\" property set to \"frame\" is
149 found within a tree, its level locally overrides this number.
151 This variable has no effect on headlines with the \"BEAMER_env\"
152 property set to either \"ignoreheading\", \"appendix\", or
153 \"note\", which will respectively, be invisible, become an
154 appendix or a note.
156 This integer is relative to the minimal level of a headline
157 within the parse tree, defined as 1."
158 :group 'org-export-beamer
159 :type 'integer)
161 (defcustom org-beamer-frame-default-options ""
162 "Default options string to use for frames.
163 For example, it could be set to \"allowframebreaks\"."
164 :group 'org-export-beamer
165 :type '(string :tag "[options]"))
167 (defcustom org-beamer-column-view-format
168 "%45ITEM %10BEAMER_env(Env) %10BEAMER_act(Act) %4BEAMER_col(Col) %8BEAMER_opt(Opt)"
169 "Column view format that should be used to fill the template."
170 :group 'org-export-beamer
171 :version "24.4"
172 :package-version '(Org . "8.0")
173 :type '(choice
174 (const :tag "Do not insert Beamer column view format" nil)
175 (string :tag "Beamer column view format")))
177 (defcustom org-beamer-theme "default"
178 "Default theme used in Beamer presentations."
179 :group 'org-export-beamer
180 :version "24.4"
181 :package-version '(Org . "8.0")
182 :type '(choice
183 (const :tag "Do not insert a Beamer theme" nil)
184 (string :tag "Beamer theme")))
186 (defcustom org-beamer-environments-extra nil
187 "Environments triggered by tags in Beamer export.
188 Each entry has 4 elements:
190 name Name of the environment
191 key Selection key for `org-beamer-select-environment'
192 open The opening template for the environment, with the following escapes
193 %a the action/overlay specification
194 %A the default action/overlay specification
195 %o the options argument of the template
196 %h the headline text
197 %r the raw headline text (i.e. without any processing)
198 %H if there is headline text, that raw text in {} braces
199 %U if there is headline text, that raw text in [] brackets
200 close The closing string of the environment."
201 :group 'org-export-beamer
202 :version "24.4"
203 :package-version '(Org . "8.1")
204 :type '(repeat
205 (list
206 (string :tag "Environment")
207 (string :tag "Selection key")
208 (string :tag "Begin")
209 (string :tag "End"))))
211 (defcustom org-beamer-outline-frame-title "Outline"
212 "Default title of a frame containing an outline."
213 :group 'org-export-beamer
214 :type '(string :tag "Outline frame title"))
216 (defcustom org-beamer-outline-frame-options ""
217 "Outline frame options appended after \\begin{frame}.
218 You might want to put e.g. \"allowframebreaks=0.9\" here."
219 :group 'org-export-beamer
220 :type '(string :tag "Outline frame options"))
224 ;;; Internal Variables
226 (defconst org-beamer-column-widths
227 "0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.0 :ETC"
228 "The column widths that should be installed as allowed property values.")
230 (defconst org-beamer-environments-special
231 '(("againframe" "A")
232 ("appendix" "x")
233 ("column" "c")
234 ("columns" "C")
235 ("frame" "f")
236 ("fullframe" "F")
237 ("ignoreheading" "i")
238 ("note" "n")
239 ("noteNH" "N"))
240 "Alist of environments treated in a special way by the back-end.
241 Keys are environment names, as strings, values are bindings used
242 in `org-beamer-select-environment'. Environments listed here,
243 along with their binding, are hard coded and cannot be modified
244 through `org-beamer-environments-extra' variable.")
246 (defconst org-beamer-environments-default
247 '(("block" "b" "\\begin{block}%a{%h}" "\\end{block}")
248 ("alertblock" "a" "\\begin{alertblock}%a{%h}" "\\end{alertblock}")
249 ("verse" "v" "\\begin{verse}%a %% %h" "\\end{verse}")
250 ("quotation" "q" "\\begin{quotation}%a %% %h" "\\end{quotation}")
251 ("quote" "Q" "\\begin{quote}%a %% %h" "\\end{quote}")
252 ("structureenv" "s" "\\begin{structureenv}%a %% %h" "\\end{structureenv}")
253 ("theorem" "t" "\\begin{theorem}%a%U" "\\end{theorem}")
254 ("definition" "d" "\\begin{definition}%a%U" "\\end{definition}")
255 ("example" "e" "\\begin{example}%a%U" "\\end{example}")
256 ("exampleblock" "E" "\\begin{exampleblock}%a{%h}" "\\end{exampleblock}")
257 ("proof" "p" "\\begin{proof}%a%U" "\\end{proof}")
258 ("beamercolorbox" "o" "\\begin{beamercolorbox}%o{%h}" "\\end{beamercolorbox}"))
259 "Environments triggered by properties in Beamer export.
260 These are the defaults - for user definitions, see
261 `org-beamer-environments-extra'.")
263 (defconst org-beamer-verbatim-elements
264 '(code example-block fixed-width inline-src-block src-block verbatim)
265 "List of element or object types producing verbatim text.
266 This is used internally to determine when a frame should have the
267 \"fragile\" option.")
271 ;;; Internal functions
273 (defun org-beamer--normalize-argument (argument type)
274 "Return ARGUMENT string with proper boundaries.
276 TYPE is a symbol among the following:
277 `action' Return ARGUMENT within angular brackets.
278 `defaction' Return ARGUMENT within both square and angular brackets.
279 `option' Return ARGUMENT within square brackets."
280 (if (not (string-match "\\S-" argument)) ""
281 (case type
282 (action (if (string-match "\\`<.*>\\'" argument) argument
283 (format "<%s>" argument)))
284 (defaction (cond
285 ((string-match "\\`\\[<.*>\\]\\'" argument) argument)
286 ((string-match "\\`<.*>\\'" argument)
287 (format "[%s]" argument))
288 ((string-match "\\`\\[\\(.*\\)\\]\\'" argument)
289 (format "[<%s>]" (match-string 1 argument)))
290 (t (format "[<%s>]" argument))))
291 (option (if (string-match "\\`\\[.*\\]\\'" argument) argument
292 (format "[%s]" argument)))
293 (otherwise argument))))
295 (defun org-beamer--element-has-overlay-p (element)
296 "Non-nil when ELEMENT has an overlay specified.
297 An element has an overlay specification when it starts with an
298 `beamer' export-snippet whose value is between angular brackets.
299 Return overlay specification, as a string, or nil."
300 (let ((first-object (car (org-element-contents element))))
301 (when (eq (org-element-type first-object) 'export-snippet)
302 (let ((value (org-element-property :value first-object)))
303 (and (string-match "\\`<.*>\\'" value) value)))))
307 ;;; Define Back-End
309 (org-export-define-derived-backend 'beamer 'latex
310 :export-block "BEAMER"
311 :menu-entry
312 '(?l 1
313 ((?B "As LaTeX buffer (Beamer)" org-beamer-export-as-latex)
314 (?b "As LaTeX file (Beamer)" org-beamer-export-to-latex)
315 (?P "As PDF file (Beamer)" org-beamer-export-to-pdf)
316 (?O "As PDF file and open (Beamer)"
317 (lambda (a s v b)
318 (if a (org-beamer-export-to-pdf t s v b)
319 (org-open-file (org-beamer-export-to-pdf nil s v b)))))))
320 :options-alist
321 '((:beamer-theme "BEAMER_THEME" nil org-beamer-theme)
322 (:beamer-color-theme "BEAMER_COLOR_THEME" nil nil t)
323 (:beamer-font-theme "BEAMER_FONT_THEME" nil nil t)
324 (:beamer-inner-theme "BEAMER_INNER_THEME" nil nil t)
325 (:beamer-outer-theme "BEAMER_OUTER_THEME" nil nil t)
326 (:beamer-header-extra "BEAMER_HEADER" nil nil newline)
327 ;; Modify existing properties.
328 (:headline-levels nil "H" org-beamer-frame-level)
329 (:latex-class "LATEX_CLASS" nil "beamer" t))
330 :translate-alist '((bold . org-beamer-bold)
331 (export-block . org-beamer-export-block)
332 (export-snippet . org-beamer-export-snippet)
333 (headline . org-beamer-headline)
334 (item . org-beamer-item)
335 (keyword . org-beamer-keyword)
336 (link . org-beamer-link)
337 (plain-list . org-beamer-plain-list)
338 (radio-target . org-beamer-radio-target)
339 (target . org-beamer-target)
340 (template . org-beamer-template)))
344 ;;; Transcode Functions
346 ;;;; Bold
348 (defun org-beamer-bold (bold contents info)
349 "Transcode BLOCK object into Beamer code.
350 CONTENTS is the text being bold. INFO is a plist used as
351 a communication channel."
352 (format "\\alert%s{%s}"
353 (or (org-beamer--element-has-overlay-p bold) "")
354 contents))
357 ;;;; Export Block
359 (defun org-beamer-export-block (export-block contents info)
360 "Transcode an EXPORT-BLOCK element into Beamer code.
361 CONTENTS is nil. INFO is a plist used as a communication
362 channel."
363 (when (member (org-element-property :type export-block) '("BEAMER" "LATEX"))
364 (org-remove-indentation (org-element-property :value export-block))))
367 ;;;; Export Snippet
369 (defun org-beamer-export-snippet (export-snippet contents info)
370 "Transcode an EXPORT-SNIPPET object into Beamer code.
371 CONTENTS is nil. INFO is a plist used as a communication
372 channel."
373 (let ((backend (org-export-snippet-backend export-snippet))
374 (value (org-element-property :value export-snippet)))
375 ;; Only "latex" and "beamer" snippets are retained.
376 (cond ((eq backend 'latex) value)
377 ;; Ignore "beamer" snippets specifying overlays.
378 ((and (eq backend 'beamer)
379 (or (org-export-get-previous-element export-snippet info)
380 (not (string-match "\\`<.*>\\'" value))))
381 value))))
384 ;;;; Headline
386 ;; The main function to translate a headline is
387 ;; `org-beamer-headline'.
389 ;; Depending on the level at which a headline is considered as
390 ;; a frame (given by `org-beamer--frame-level'), the headline is
391 ;; either a section (`org-beamer--format-section'), a frame
392 ;; (`org-beamer--format-frame') or a block
393 ;; (`org-beamer--format-block').
395 ;; `org-beamer-headline' also takes care of special environments
396 ;; like "ignoreheading", "note", "noteNH", "appendix" and
397 ;; "againframe".
399 (defun org-beamer--get-label (headline info)
400 "Return label for HEADLINE, as a string.
402 INFO is a plist used as a communication channel.
404 The value is either the label specified in \"BEAMER_opt\"
405 property, or a fallback value built from headline's number. This
406 function assumes HEADLINE will be treated as a frame."
407 (let ((opt (org-element-property :BEAMER_OPT headline)))
408 (if (and (org-string-nw-p opt)
409 (string-match "\\(?:^\\|,\\)label=\\(.*?\\)\\(?:$\\|,\\)" opt))
410 (match-string 1 opt)
411 (format "sec-%s"
412 (mapconcat 'number-to-string
413 (org-export-get-headline-number headline info)
414 "-")))))
416 (defun org-beamer--frame-level (headline info)
417 "Return frame level in subtree containing HEADLINE.
418 INFO is a plist used as a communication channel."
420 ;; 1. Look for "frame" environment in parents, starting from the
421 ;; farthest.
422 (catch 'exit
423 (mapc (lambda (parent)
424 (let ((env (org-element-property :BEAMER_ENV parent)))
425 (when (and env (member-ignore-case env '("frame" "fullframe")))
426 (throw 'exit (org-export-get-relative-level parent info)))))
427 (nreverse (org-export-get-genealogy headline)))
428 nil)
429 ;; 2. Look for "frame" environment in HEADLINE.
430 (let ((env (org-element-property :BEAMER_ENV headline)))
431 (and env (member-ignore-case env '("frame" "fullframe"))
432 (org-export-get-relative-level headline info)))
433 ;; 3. Look for "frame" environment in sub-tree.
434 (org-element-map headline 'headline
435 (lambda (hl)
436 (let ((env (org-element-property :BEAMER_ENV hl)))
437 (when (and env (member-ignore-case env '("frame" "fullframe")))
438 (org-export-get-relative-level hl info))))
439 info 'first-match)
440 ;; 4. No "frame" environment in tree: use default value.
441 (plist-get info :headline-levels)))
443 (defun org-beamer--format-section (headline contents info)
444 "Format HEADLINE as a sectioning part.
445 CONTENTS holds the contents of the headline. INFO is a plist
446 used as a communication channel."
447 (let ((latex-headline
448 (org-export-with-backend
449 ;; We create a temporary export back-end which behaves the
450 ;; same as current one, but adds "\protect" in front of the
451 ;; output of some objects.
452 (org-export-create-backend
453 :parent 'latex
454 :transcoders
455 (let ((protected-output
456 (function
457 (lambda (object contents info)
458 (let ((code (org-export-with-backend
459 'beamer object contents info)))
460 (if (org-string-nw-p code) (concat "\\protect" code)
461 code))))))
462 (mapcar #'(lambda (type) (cons type protected-output))
463 '(bold footnote-reference italic strike-through timestamp
464 underline))))
465 headline
466 contents
467 info))
468 (mode-specs (org-element-property :BEAMER_ACT headline)))
469 (if (and mode-specs
470 (string-match "\\`\\\\\\(.*?\\)\\(?:\\*\\|\\[.*\\]\\)?{"
471 latex-headline))
472 ;; Insert overlay specifications.
473 (replace-match (concat (match-string 1 latex-headline)
474 (format "<%s>" mode-specs))
475 nil nil latex-headline 1)
476 latex-headline)))
478 (defun org-beamer--format-frame (headline contents info)
479 "Format HEADLINE as a frame.
480 CONTENTS holds the contents of the headline. INFO is a plist
481 used as a communication channel."
482 (let ((fragilep
483 ;; FRAGILEP is non-nil when HEADLINE contains an element
484 ;; among `org-beamer-verbatim-elements'.
485 (org-element-map headline org-beamer-verbatim-elements 'identity
486 info 'first-match)))
487 (concat "\\begin{frame}"
488 ;; Overlay specification, if any. When surrounded by
489 ;; square brackets, consider it as a default
490 ;; specification.
491 (let ((action (org-element-property :BEAMER_ACT headline)))
492 (cond
493 ((not action) "")
494 ((string-match "\\`\\[.*\\]\\'" action )
495 (org-beamer--normalize-argument action 'defaction))
496 (t (org-beamer--normalize-argument action 'action))))
497 ;; Options, if any.
498 (let* ((beamer-opt (org-element-property :BEAMER_OPT headline))
499 (options
500 ;; Collect options from default value and headline's
501 ;; properties. Also add a label for links.
502 (append
503 (org-split-string org-beamer-frame-default-options ",")
504 (and beamer-opt
505 (org-split-string
506 ;; Remove square brackets if user provided
507 ;; them.
508 (and (string-match "^\\[?\\(.*\\)\\]?$" beamer-opt)
509 (match-string 1 beamer-opt))
510 ","))
511 ;; Provide an automatic label for the frame
512 ;; unless the user specified one.
513 (unless (and beamer-opt
514 (string-match "\\(^\\|,\\)label=" beamer-opt))
515 (list
516 (format "label=%s"
517 (org-beamer--get-label headline info)))))))
518 ;; Change options list into a string.
519 (org-beamer--normalize-argument
520 (mapconcat
521 'identity
522 (if (or (not fragilep) (member "fragile" options)) options
523 (cons "fragile" options))
524 ",")
525 'option))
526 ;; Title.
527 (let ((env (org-element-property :BEAMER_ENV headline)))
528 (format "{%s}"
529 (if (and env (equal (downcase env) "fullframe")) ""
530 (org-export-data
531 (org-element-property :title headline) info))))
532 "\n"
533 ;; The following workaround is required in fragile frames
534 ;; as Beamer will append "\par" to the beginning of the
535 ;; contents. So we need to make sure the command is
536 ;; separated from the contents by at least one space. If
537 ;; it isn't, it will create "\parfirst-word" command and
538 ;; remove the first word from the contents in the PDF
539 ;; output.
540 (if (not fragilep) contents
541 (replace-regexp-in-string "\\`\n*" "\\& " (or contents "")))
542 "\\end{frame}")))
544 (defun org-beamer--format-block (headline contents info)
545 "Format HEADLINE as a block.
546 CONTENTS holds the contents of the headline. INFO is a plist
547 used as a communication channel."
548 (let* ((column-width (org-element-property :BEAMER_COL headline))
549 ;; ENVIRONMENT defaults to "block" if none is specified and
550 ;; there is no column specification. If there is a column
551 ;; specified but still no explicit environment, ENVIRONMENT
552 ;; is "column".
553 (environment (let ((env (org-element-property :BEAMER_ENV headline)))
554 (cond
555 ;; "block" is the fallback environment.
556 ((and (not env) (not column-width)) "block")
557 ;; "column" only.
558 ((not env) "column")
559 ;; Use specified environment.
560 (t env))))
561 (raw-title (org-element-property :raw-value headline))
562 (env-format
563 (cond ((member environment '("column" "columns")) nil)
564 ((assoc environment
565 (append org-beamer-environments-extra
566 org-beamer-environments-default)))
567 (t (user-error "Wrong block type at a headline named \"%s\""
568 raw-title))))
569 (title (org-export-data (org-element-property :title headline) info))
570 (options (let ((options (org-element-property :BEAMER_OPT headline)))
571 (if (not options) ""
572 (org-beamer--normalize-argument options 'option))))
573 ;; Start a "columns" environment when explicitly requested or
574 ;; when there is no previous headline or the previous
575 ;; headline do not have a BEAMER_column property.
576 (parent-env (org-element-property
577 :BEAMER_ENV (org-export-get-parent-headline headline)))
578 (start-columns-p
579 (or (equal environment "columns")
580 (and column-width
581 (not (and parent-env
582 (equal (downcase parent-env) "columns")))
583 (or (org-export-first-sibling-p headline info)
584 (not (org-element-property
585 :BEAMER_COL
586 (org-export-get-previous-element
587 headline info)))))))
588 ;; End the "columns" environment when explicitly requested or
589 ;; when there is no next headline or the next headline do not
590 ;; have a BEAMER_column property.
591 (end-columns-p
592 (or (equal environment "columns")
593 (and column-width
594 (not (and parent-env
595 (equal (downcase parent-env) "columns")))
596 (or (org-export-last-sibling-p headline info)
597 (not (org-element-property
598 :BEAMER_COL
599 (org-export-get-next-element headline info))))))))
600 (concat
601 (when start-columns-p
602 ;; Column can accept options only when the environment is
603 ;; explicitly defined.
604 (if (not (equal environment "columns")) "\\begin{columns}\n"
605 (format "\\begin{columns}%s\n" options)))
606 (when column-width
607 (format "\\begin{column}%s{%s}\n"
608 ;; One can specify placement for column only when
609 ;; HEADLINE stands for a column on its own.
610 (if (equal environment "column") options "")
611 (format "%s\\textwidth" column-width)))
612 ;; Block's opening string.
613 (when (nth 2 env-format)
614 (concat
615 (org-fill-template
616 (nth 2 env-format)
617 (nconc
618 ;; If BEAMER_act property has its value enclosed in square
619 ;; brackets, it is a default overlay specification and
620 ;; overlay specification is empty. Otherwise, it is an
621 ;; overlay specification and the default one is nil.
622 (let ((action (org-element-property :BEAMER_ACT headline)))
623 (cond
624 ((not action) (list (cons "a" "") (cons "A" "")))
625 ((string-match "\\`\\[.*\\]\\'" action)
626 (list
627 (cons "A" (org-beamer--normalize-argument action 'defaction))
628 (cons "a" "")))
630 (list (cons "a" (org-beamer--normalize-argument action 'action))
631 (cons "A" "")))))
632 (list (cons "o" options)
633 (cons "h" title)
634 (cons "r" raw-title)
635 (cons "H" (if (equal raw-title "") ""
636 (format "{%s}" raw-title)))
637 (cons "U" (if (equal raw-title "") ""
638 (format "[%s]" raw-title))))))
639 "\n"))
640 contents
641 ;; Block's closing string, if any.
642 (and (nth 3 env-format) (concat (nth 3 env-format) "\n"))
643 (when column-width "\\end{column}\n")
644 (when end-columns-p "\\end{columns}"))))
646 (defun org-beamer-headline (headline contents info)
647 "Transcode HEADLINE element into Beamer code.
648 CONTENTS is the contents of the headline. INFO is a plist used
649 as a communication channel."
650 (unless (org-element-property :footnote-section-p headline)
651 (let ((level (org-export-get-relative-level headline info))
652 (frame-level (org-beamer--frame-level headline info))
653 (environment (let ((env (org-element-property :BEAMER_ENV headline)))
654 (or (org-string-nw-p env) "block"))))
655 (cond
656 ;; Case 1: Resume frame specified by "BEAMER_ref" property.
657 ((equal environment "againframe")
658 (let ((ref (org-element-property :BEAMER_REF headline)))
659 ;; Reference to frame being resumed is mandatory. Ignore
660 ;; the whole headline if it isn't provided.
661 (when (org-string-nw-p ref)
662 (concat "\\againframe"
663 ;; Overlay specification.
664 (let ((overlay (org-element-property :BEAMER_ACT headline)))
665 (when overlay
666 (org-beamer--normalize-argument
667 overlay
668 (if (string-match "^\\[.*\\]$" overlay) 'defaction
669 'action))))
670 ;; Options.
671 (let ((options (org-element-property :BEAMER_OPT headline)))
672 (when options
673 (org-beamer--normalize-argument options 'option)))
674 ;; Resolve reference provided by "BEAMER_ref"
675 ;; property. This is done by building a minimal fake
676 ;; link and calling the appropriate resolve function,
677 ;; depending on the reference syntax.
678 (let* ((type
679 (progn
680 (string-match "^\\(id:\\|#\\|\\*\\)?\\(.*\\)" ref)
681 (cond
682 ((or (not (match-string 1 ref))
683 (equal (match-string 1 ref) "*")) 'fuzzy)
684 ((equal (match-string 1 ref) "id:") 'id)
685 (t 'custom-id))))
686 (link (list 'link (list :path (match-string 2 ref))))
687 (target (if (eq type 'fuzzy)
688 (org-export-resolve-fuzzy-link link info)
689 (org-export-resolve-id-link link info))))
690 ;; Now use user-defined label provided in TARGET
691 ;; headline, or fallback to standard one.
692 (format "{%s}" (org-beamer--get-label target info)))))))
693 ;; Case 2: Creation of an appendix is requested.
694 ((equal environment "appendix")
695 (concat "\\appendix"
696 (org-element-property :BEAMER_ACT headline)
697 "\n"
698 (make-string (org-element-property :pre-blank headline) ?\n)
699 contents))
700 ;; Case 3: Ignore heading.
701 ((equal environment "ignoreheading")
702 (concat (make-string (org-element-property :pre-blank headline) ?\n)
703 contents))
704 ;; Case 4: HEADLINE is a note.
705 ((member environment '("note" "noteNH"))
706 (format "\\note{%s}"
707 (concat (and (equal environment "note")
708 (concat
709 (org-export-data
710 (org-element-property :title headline) info)
711 "\n"))
712 (org-trim contents))))
713 ;; Case 5: HEADLINE is a frame.
714 ((= level frame-level)
715 (org-beamer--format-frame headline contents info))
716 ;; Case 6: Regular section, extracted from
717 ;; `org-latex-classes'.
718 ((< level frame-level)
719 (org-beamer--format-section headline contents info))
720 ;; Case 7: Otherwise, HEADLINE is a block.
721 (t (org-beamer--format-block headline contents info))))))
724 ;;;; Item
726 (defun org-beamer-item (item contents info)
727 "Transcode an ITEM element into Beamer code.
728 CONTENTS holds the contents of the item. INFO is a plist holding
729 contextual information."
730 (let ((action (let ((first-element (car (org-element-contents item))))
731 (and (eq (org-element-type first-element) 'paragraph)
732 (org-beamer--element-has-overlay-p first-element))))
733 (output (org-export-with-backend 'latex item contents info)))
734 (if (not action) output
735 ;; If the item starts with a paragraph and that paragraph starts
736 ;; with an export snippet specifying an overlay, insert it after
737 ;; \item command.
738 (replace-regexp-in-string "\\\\item" (concat "\\\\item" action) output))))
741 ;;;; Keyword
743 (defun org-beamer-keyword (keyword contents info)
744 "Transcode a KEYWORD element into Beamer code.
745 CONTENTS is nil. INFO is a plist used as a communication
746 channel."
747 (let ((key (org-element-property :key keyword))
748 (value (org-element-property :value keyword)))
749 ;; Handle specifically BEAMER and TOC (headlines only) keywords.
750 ;; Otherwise, fallback to `latex' back-end.
751 (cond
752 ((equal key "BEAMER") value)
753 ((and (equal key "TOC") (string-match "\\<headlines\\>" value))
754 (let ((depth (or (and (string-match "[0-9]+" value)
755 (string-to-number (match-string 0 value)))
756 (plist-get info :with-toc)))
757 (options (and (string-match "\\[.*?\\]" value)
758 (match-string 0 value))))
759 (concat
760 (when (wholenump depth) (format "\\setcounter{tocdepth}{%s}\n" depth))
761 "\\tableofcontents" options)))
762 (t (org-export-with-backend 'latex keyword contents info)))))
765 ;;;; Link
767 (defun org-beamer-link (link contents info)
768 "Transcode a LINK object into Beamer code.
769 CONTENTS is the description part of the link. INFO is a plist
770 used as a communication channel."
771 (let ((type (org-element-property :type link))
772 (path (org-element-property :path link)))
773 ;; Use \hyperlink command for all internal links.
774 (cond
775 ((equal type "radio")
776 (let ((destination (org-export-resolve-radio-link link info)))
777 (when destination
778 (format "\\hyperlink%s{%s}{%s}"
779 (or (org-beamer--element-has-overlay-p link) "")
780 (org-export-solidify-link-text path)
781 (org-export-data (org-element-contents destination) info)))))
782 ((and (member type '("custom-id" "fuzzy" "id"))
783 (let ((destination (if (string= type "fuzzy")
784 (org-export-resolve-fuzzy-link link info)
785 (org-export-resolve-id-link link info))))
786 (case (org-element-type destination)
787 (headline
788 (let ((label
789 (format "sec-%s"
790 (mapconcat
791 'number-to-string
792 (org-export-get-headline-number
793 destination info)
794 "-"))))
795 (if (and (plist-get info :section-numbers) (not contents))
796 (format "\\ref{%s}" label)
797 (format "\\hyperlink%s{%s}{%s}"
798 (or (org-beamer--element-has-overlay-p link) "")
799 label
800 contents))))
801 (target
802 (let ((path (org-export-solidify-link-text path)))
803 (if (not contents) (format "\\ref{%s}" path)
804 (format "\\hyperlink%s{%s}{%s}"
805 (or (org-beamer--element-has-overlay-p link) "")
806 path
807 contents))))))))
808 ;; Otherwise, use `latex' back-end.
809 (t (org-export-with-backend 'latex link contents info)))))
812 ;;;; Plain List
814 ;; Plain lists support `:environment', `:overlay' and `:options'
815 ;; attributes.
817 (defun org-beamer-plain-list (plain-list contents info)
818 "Transcode a PLAIN-LIST element into Beamer code.
819 CONTENTS is the contents of the list. INFO is a plist holding
820 contextual information."
821 (let* ((type (org-element-property :type plain-list))
822 (attributes (org-combine-plists
823 (org-export-read-attribute :attr_latex plain-list)
824 (org-export-read-attribute :attr_beamer plain-list)))
825 (latex-type (let ((env (plist-get attributes :environment)))
826 (cond (env)
827 ((eq type 'ordered) "enumerate")
828 ((eq type 'descriptive) "description")
829 (t "itemize")))))
830 (org-latex--wrap-label
831 plain-list
832 (format "\\begin{%s}%s%s\n%s\\end{%s}"
833 latex-type
834 ;; Default overlay specification, if any.
835 (org-beamer--normalize-argument
836 (or (plist-get attributes :overlay) "")
837 'defaction)
838 ;; Second optional argument depends on the list type.
839 (org-beamer--normalize-argument
840 (or (plist-get attributes :options) "")
841 'option)
842 ;; Eventually insert contents and close environment.
843 contents
844 latex-type))))
847 ;;;; Radio Target
849 (defun org-beamer-radio-target (radio-target text info)
850 "Transcode a RADIO-TARGET object into Beamer code.
851 TEXT is the text of the target. INFO is a plist holding
852 contextual information."
853 (format "\\hypertarget%s{%s}{%s}"
854 (or (org-beamer--element-has-overlay-p radio-target) "")
855 (org-export-solidify-link-text
856 (org-element-property :value radio-target))
857 text))
860 ;;;; Target
862 (defun org-beamer-target (target contents info)
863 "Transcode a TARGET object into Beamer code.
864 CONTENTS is nil. INFO is a plist holding contextual
865 information."
866 (format "\\hypertarget{%s}{}"
867 (org-export-solidify-link-text (org-element-property :value target))))
870 ;;;; Template
872 ;; Template used is similar to the one used in `latex' back-end,
873 ;; excepted for the table of contents and Beamer themes.
875 (defun org-beamer-template (contents info)
876 "Return complete document string after Beamer conversion.
877 CONTENTS is the transcoded contents string. INFO is a plist
878 holding export options."
879 (let ((title (org-export-data (plist-get info :title) info)))
880 (concat
881 ;; 1. Time-stamp.
882 (and (plist-get info :time-stamp-file)
883 (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
884 ;; 2. Document class and packages.
885 (let* ((class (plist-get info :latex-class))
886 (class-options (plist-get info :latex-class-options))
887 (header (nth 1 (assoc class org-latex-classes)))
888 (document-class-string
889 (and (stringp header)
890 (if (not class-options) header
891 (replace-regexp-in-string
892 "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
893 class-options header t nil 1)))))
894 (if (not document-class-string)
895 (user-error "Unknown LaTeX class `%s'" class)
896 (org-latex-guess-babel-language
897 (org-latex-guess-inputenc
898 (org-element-normalize-string
899 (org-splice-latex-header
900 document-class-string
901 org-latex-default-packages-alist
902 org-latex-packages-alist nil
903 (concat (org-element-normalize-string
904 (plist-get info :latex-header))
905 (org-element-normalize-string
906 (plist-get info :latex-header-extra))
907 (plist-get info :beamer-header-extra)))))
908 info)))
909 ;; 3. Insert themes.
910 (let ((format-theme
911 (function
912 (lambda (prop command)
913 (let ((theme (plist-get info prop)))
914 (when theme
915 (concat command
916 (if (not (string-match "\\[.*\\]" theme))
917 (format "{%s}\n" theme)
918 (format "%s{%s}\n"
919 (match-string 0 theme)
920 (org-trim
921 (replace-match "" nil nil theme)))))))))))
922 (mapconcat (lambda (args) (apply format-theme args))
923 '((:beamer-theme "\\usetheme")
924 (:beamer-color-theme "\\usecolortheme")
925 (:beamer-font-theme "\\usefonttheme")
926 (:beamer-inner-theme "\\useinnertheme")
927 (:beamer-outer-theme "\\useoutertheme"))
928 ""))
929 ;; 4. Possibly limit depth for headline numbering.
930 (let ((sec-num (plist-get info :section-numbers)))
931 (when (integerp sec-num)
932 (format "\\setcounter{secnumdepth}{%d}\n" sec-num)))
933 ;; 5. Author.
934 (let ((author (and (plist-get info :with-author)
935 (let ((auth (plist-get info :author)))
936 (and auth (org-export-data auth info)))))
937 (email (and (plist-get info :with-email)
938 (org-export-data (plist-get info :email) info))))
939 (cond ((and author email (not (string= "" email)))
940 (format "\\author{%s\\thanks{%s}}\n" author email))
941 (author (format "\\author{%s}\n" author))
942 (t "\\author{}\n")))
943 ;; 6. Date.
944 (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
945 (format "\\date{%s}\n" (org-export-data date info)))
946 ;; 7. Title
947 (format "\\title{%s}\n" title)
948 ;; 8. Hyperref options.
949 (when (plist-get info :latex-hyperref-p)
950 (format "\\hypersetup{\n pdfkeywords={%s},\n pdfsubject={%s},\n pdfcreator={%s}}\n"
951 (or (plist-get info :keywords) "")
952 (or (plist-get info :description) "")
953 (if (not (plist-get info :with-creator)) ""
954 (plist-get info :creator))))
955 ;; 9. Document start.
956 "\\begin{document}\n\n"
957 ;; 10. Title command.
958 (org-element-normalize-string
959 (cond ((string= "" title) nil)
960 ((not (stringp org-latex-title-command)) nil)
961 ((string-match "\\(?:[^%]\\|^\\)%s"
962 org-latex-title-command)
963 (format org-latex-title-command title))
964 (t org-latex-title-command)))
965 ;; 11. Table of contents.
966 (let ((depth (plist-get info :with-toc)))
967 (when depth
968 (concat
969 (format "\\begin{frame}%s{%s}\n"
970 (org-beamer--normalize-argument
971 org-beamer-outline-frame-options 'option)
972 org-beamer-outline-frame-title)
973 (when (wholenump depth)
974 (format "\\setcounter{tocdepth}{%d}\n" depth))
975 "\\tableofcontents\n"
976 "\\end{frame}\n\n")))
977 ;; 12. Document's body.
978 contents
979 ;; 13. Creator.
980 (let ((creator-info (plist-get info :with-creator)))
981 (cond
982 ((not creator-info) "")
983 ((eq creator-info 'comment)
984 (format "%% %s\n" (plist-get info :creator)))
985 (t (concat (plist-get info :creator) "\n"))))
986 ;; 14. Document end.
987 "\\end{document}")))
991 ;;; Minor Mode
994 (defvar org-beamer-mode-map (make-sparse-keymap)
995 "The keymap for `org-beamer-mode'.")
996 (define-key org-beamer-mode-map "\C-c\C-b" 'org-beamer-select-environment)
998 ;;;###autoload
999 (define-minor-mode org-beamer-mode
1000 "Support for editing Beamer oriented Org mode files."
1001 nil " Bm" 'org-beamer-mode-map)
1003 (when (fboundp 'font-lock-add-keywords)
1004 (font-lock-add-keywords
1005 'org-mode
1006 '((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
1007 'prepend))
1009 (defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
1010 "The special face for beamer tags."
1011 :group 'org-export-beamer)
1013 (defun org-beamer-property-changed (property value)
1014 "Track the BEAMER_env property with tags.
1015 PROPERTY is the name of the modified property. VALUE is its new
1016 value."
1017 (cond
1018 ((equal property "BEAMER_env")
1019 (save-excursion
1020 (org-back-to-heading t)
1021 ;; Filter out Beamer-related tags and install environment tag.
1022 (let ((tags (org-remove-if (lambda (x) (string-match "^B_" x))
1023 (org-get-tags)))
1024 (env-tag (and (org-string-nw-p value) (concat "B_" value))))
1025 (org-set-tags-to (if env-tag (cons env-tag tags) tags))
1026 (when env-tag (org-toggle-tag env-tag 'on)))))
1027 ((equal property "BEAMER_col")
1028 (org-toggle-tag "BMCOL" (if (org-string-nw-p value) 'on 'off)))))
1030 (add-hook 'org-property-changed-functions 'org-beamer-property-changed)
1032 (defun org-beamer-allowed-property-values (property)
1033 "Supply allowed values for PROPERTY."
1034 (cond
1035 ((and (equal property "BEAMER_env")
1036 (not (org-entry-get nil (concat property "_ALL") 'inherit)))
1037 ;; If no allowed values for BEAMER_env have been defined,
1038 ;; supply all defined environments
1039 (mapcar 'car (append org-beamer-environments-special
1040 org-beamer-environments-extra
1041 org-beamer-environments-default)))
1042 ((and (equal property "BEAMER_col")
1043 (not (org-entry-get nil (concat property "_ALL") 'inherit)))
1044 ;; If no allowed values for BEAMER_col have been defined,
1045 ;; supply some
1046 (org-split-string org-beamer-column-widths " "))))
1048 (add-hook 'org-property-allowed-value-functions
1049 'org-beamer-allowed-property-values)
1053 ;;; Commands
1055 ;;;###autoload
1056 (defun org-beamer-export-as-latex
1057 (&optional async subtreep visible-only body-only ext-plist)
1058 "Export current buffer as a Beamer buffer.
1060 If narrowing is active in the current buffer, only export its
1061 narrowed part.
1063 If a region is active, export that region.
1065 A non-nil optional argument ASYNC means the process should happen
1066 asynchronously. The resulting buffer should be accessible
1067 through the `org-export-stack' interface.
1069 When optional argument SUBTREEP is non-nil, export the sub-tree
1070 at point, extracting information from the headline properties
1071 first.
1073 When optional argument VISIBLE-ONLY is non-nil, don't export
1074 contents of hidden elements.
1076 When optional argument BODY-ONLY is non-nil, only write code
1077 between \"\\begin{document}\" and \"\\end{document}\".
1079 EXT-PLIST, when provided, is a property list with external
1080 parameters overriding Org default settings, but still inferior to
1081 file-local settings.
1083 Export is done in a buffer named \"*Org BEAMER Export*\", which
1084 will be displayed when `org-export-show-temporary-export-buffer'
1085 is non-nil."
1086 (interactive)
1087 (org-export-to-buffer 'beamer "*Org BEAMER Export*"
1088 async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
1090 ;;;###autoload
1091 (defun org-beamer-export-to-latex
1092 (&optional async subtreep visible-only body-only ext-plist)
1093 "Export current buffer as a Beamer presentation (tex).
1095 If narrowing is active in the current buffer, only export its
1096 narrowed part.
1098 If a region is active, export that region.
1100 A non-nil optional argument ASYNC means the process should happen
1101 asynchronously. The resulting file should be accessible through
1102 the `org-export-stack' interface.
1104 When optional argument SUBTREEP is non-nil, export the sub-tree
1105 at point, extracting information from the headline properties
1106 first.
1108 When optional argument VISIBLE-ONLY is non-nil, don't export
1109 contents of hidden elements.
1111 When optional argument BODY-ONLY is non-nil, only write code
1112 between \"\\begin{document}\" and \"\\end{document}\".
1114 EXT-PLIST, when provided, is a property list with external
1115 parameters overriding Org default settings, but still inferior to
1116 file-local settings.
1118 Return output file's name."
1119 (interactive)
1120 (let ((file (org-export-output-file-name ".tex" subtreep)))
1121 (org-export-to-file 'beamer file
1122 async subtreep visible-only body-only ext-plist)))
1124 ;;;###autoload
1125 (defun org-beamer-export-to-pdf
1126 (&optional async subtreep visible-only body-only ext-plist)
1127 "Export current buffer as a Beamer presentation (PDF).
1129 If narrowing is active in the current buffer, only export its
1130 narrowed part.
1132 If a region is active, export that region.
1134 A non-nil optional argument ASYNC means the process should happen
1135 asynchronously. The resulting file should be accessible through
1136 the `org-export-stack' interface.
1138 When optional argument SUBTREEP is non-nil, export the sub-tree
1139 at point, extracting information from the headline properties
1140 first.
1142 When optional argument VISIBLE-ONLY is non-nil, don't export
1143 contents of hidden elements.
1145 When optional argument BODY-ONLY is non-nil, only write code
1146 between \"\\begin{document}\" and \"\\end{document}\".
1148 EXT-PLIST, when provided, is a property list with external
1149 parameters overriding Org default settings, but still inferior to
1150 file-local settings.
1152 Return PDF file's name."
1153 (interactive)
1154 (let ((file (org-export-output-file-name ".tex" subtreep)))
1155 (org-export-to-file 'beamer file
1156 async subtreep visible-only body-only ext-plist
1157 (lambda (file) (org-latex-compile file)))))
1159 ;;;###autoload
1160 (defun org-beamer-select-environment ()
1161 "Select the environment to be used by beamer for this entry.
1162 While this uses (for convenience) a tag selection interface, the
1163 result of this command will be that the BEAMER_env *property* of
1164 the entry is set.
1166 In addition to this, the command will also set a tag as a visual
1167 aid, but the tag does not have any semantic meaning."
1168 (interactive)
1169 ;; Make sure `org-beamer-environments-special' has a higher
1170 ;; priority than `org-beamer-environments-extra'.
1171 (let* ((envs (append org-beamer-environments-special
1172 org-beamer-environments-extra
1173 org-beamer-environments-default))
1174 (org-tag-alist
1175 (append '((:startgroup))
1176 (mapcar (lambda (e) (cons (concat "B_" (car e))
1177 (string-to-char (nth 1 e))))
1178 envs)
1179 '((:endgroup))
1180 '(("BMCOL" . ?|))))
1181 (org-fast-tag-selection-single-key t))
1182 (org-set-tags)
1183 (let ((tags (or (ignore-errors (org-get-tags-string)) "")))
1184 (cond
1185 ;; For a column, automatically ask for its width.
1186 ((eq org-last-tag-selection-key ?|)
1187 (if (string-match ":BMCOL:" tags)
1188 (org-set-property "BEAMER_col" (read-string "Column width: "))
1189 (org-delete-property "BEAMER_col")))
1190 ;; For an "againframe" section, automatically ask for reference
1191 ;; to resumed frame and overlay specifications.
1192 ((eq org-last-tag-selection-key ?A)
1193 (if (equal (org-entry-get nil "BEAMER_env") "againframe")
1194 (progn (org-entry-delete nil "BEAMER_env")
1195 (org-entry-delete nil "BEAMER_ref")
1196 (org-entry-delete nil "BEAMER_act"))
1197 (org-entry-put nil "BEAMER_env" "againframe")
1198 (org-set-property
1199 "BEAMER_ref"
1200 (read-string "Frame reference (*Title, #custom-id, id:...): "))
1201 (org-set-property "BEAMER_act"
1202 (read-string "Overlay specification: "))))
1203 ((string-match (concat ":B_\\(" (mapconcat 'car envs "\\|") "\\):") tags)
1204 (org-entry-put nil "BEAMER_env" (match-string 1 tags)))
1205 (t (org-entry-delete nil "BEAMER_env"))))))
1207 ;;;###autoload
1208 (defun org-beamer-insert-options-template (&optional kind)
1209 "Insert a settings template, to make sure users do this right."
1210 (interactive (progn
1211 (message "Current [s]ubtree or [g]lobal?")
1212 (if (eq (read-char-exclusive) ?g) (list 'global)
1213 (list 'subtree))))
1214 (if (eq kind 'subtree)
1215 (progn
1216 (org-back-to-heading t)
1217 (org-reveal)
1218 (org-entry-put nil "EXPORT_LaTeX_CLASS" "beamer")
1219 (org-entry-put nil "EXPORT_LaTeX_CLASS_OPTIONS" "[presentation]")
1220 (org-entry-put nil "EXPORT_FILE_NAME" "presentation.pdf")
1221 (when org-beamer-column-view-format
1222 (org-entry-put nil "COLUMNS" org-beamer-column-view-format))
1223 (org-entry-put nil "BEAMER_col_ALL" org-beamer-column-widths))
1224 (insert "#+LaTeX_CLASS: beamer\n")
1225 (insert "#+LaTeX_CLASS_OPTIONS: [presentation]\n")
1226 (when org-beamer-theme (insert "#+BEAMER_THEME: " org-beamer-theme "\n"))
1227 (when org-beamer-column-view-format
1228 (insert "#+COLUMNS: " org-beamer-column-view-format "\n"))
1229 (insert "#+PROPERTY: BEAMER_col_ALL " org-beamer-column-widths "\n")))
1231 ;;;###autoload
1232 (defun org-beamer-publish-to-latex (plist filename pub-dir)
1233 "Publish an Org file to a Beamer presentation (LaTeX).
1235 FILENAME is the filename of the Org file to be published. PLIST
1236 is the property list for the given project. PUB-DIR is the
1237 publishing directory.
1239 Return output file name."
1240 (org-publish-org-to 'beamer filename ".tex" plist pub-dir))
1242 ;;;###autoload
1243 (defun org-beamer-publish-to-pdf (plist filename pub-dir)
1244 "Publish an Org file to a Beamer presentation (PDF, via LaTeX).
1246 FILENAME is the filename of the Org file to be published. PLIST
1247 is the property list for the given project. PUB-DIR is the
1248 publishing directory.
1250 Return output file name."
1251 ;; Unlike to `org-beamer-publish-to-latex', PDF file is generated in
1252 ;; working directory and then moved to publishing directory.
1253 (org-publish-attachment
1254 plist
1255 (org-latex-compile (org-publish-org-to 'beamer filename ".tex" plist))
1256 pub-dir))
1259 (provide 'ox-beamer)
1261 ;; Local variables:
1262 ;; generated-autoload-file: "org-loaddefs.el"
1263 ;; End:
1265 ;;; ox-beamer.el ends here