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