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