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