Fix check-box toggling when point is on a link at an item
[org-mode.git] / lisp / ox-beamer.el
bloba975d242be63181d57ad8161b872e5c79fc10faf
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 (raw-title (org-element-property :raw-value headline))
543 (env-format
544 (cond ((member environment '("column" "columns")) nil)
545 ((assoc environment
546 (append org-beamer-environments-extra
547 org-beamer-environments-default)))
548 (t (user-error "Wrong block type at a headline named \"%s\""
549 raw-title))))
550 (title (org-export-data (org-element-property :title headline) info))
551 (options (let ((options (org-element-property :BEAMER_OPT headline)))
552 (if (not options) ""
553 (org-beamer--normalize-argument options 'option))))
554 ;; Start a "columns" environment when explicitly requested or
555 ;; when there is no previous headline or the previous
556 ;; headline do not have a BEAMER_column property.
557 (parent-env (org-element-property
558 :BEAMER_ENV (org-export-get-parent-headline headline)))
559 (start-columns-p
560 (or (equal environment "columns")
561 (and column-width
562 (not (and parent-env
563 (equal (downcase parent-env) "columns")))
564 (or (org-export-first-sibling-p headline info)
565 (not (org-element-property
566 :BEAMER_COL
567 (org-export-get-previous-element
568 headline info)))))))
569 ;; End the "columns" environment when explicitly requested or
570 ;; when there is no next headline or the next headline do not
571 ;; have a BEAMER_column property.
572 (end-columns-p
573 (or (equal environment "columns")
574 (and column-width
575 (not (and parent-env
576 (equal (downcase parent-env) "columns")))
577 (or (org-export-last-sibling-p headline info)
578 (not (org-element-property
579 :BEAMER_COL
580 (org-export-get-next-element headline info))))))))
581 (concat
582 (when start-columns-p
583 ;; Column can accept options only when the environment is
584 ;; explicitly defined.
585 (if (not (equal environment "columns")) "\\begin{columns}\n"
586 (format "\\begin{columns}%s\n" options)))
587 (when column-width
588 (format "\\begin{column}%s{%s}\n"
589 ;; One can specify placement for column only when
590 ;; HEADLINE stands for a column on its own.
591 (if (equal environment "column") options "")
592 (format "%s\\textwidth" column-width)))
593 ;; Block's opening string.
594 (when (nth 2 env-format)
595 (concat
596 (org-fill-template
597 (nth 2 env-format)
598 (nconc
599 ;; If BEAMER_act property has its value enclosed in square
600 ;; brackets, it is a default overlay specification and
601 ;; overlay specification is empty. Otherwise, it is an
602 ;; overlay specification and the default one is nil.
603 (let ((action (org-element-property :BEAMER_ACT headline)))
604 (cond
605 ((not action) (list (cons "a" "") (cons "A" "")))
606 ((string-match "\\`\\[.*\\]\\'" action)
607 (list
608 (cons "A" (org-beamer--normalize-argument action 'defaction))
609 (cons "a" "")))
611 (list (cons "a" (org-beamer--normalize-argument action 'action))
612 (cons "A" "")))))
613 (list (cons "o" options)
614 (cons "h" title)
615 (cons "r" raw-title)
616 (cons "H" (if (equal raw-title "") ""
617 (format "{%s}" raw-title)))
618 (cons "U" (if (equal raw-title "") ""
619 (format "[%s]" raw-title))))))
620 "\n"))
621 contents
622 ;; Block's closing string, if any.
623 (and (nth 3 env-format) (concat (nth 3 env-format) "\n"))
624 (when column-width "\\end{column}\n")
625 (when end-columns-p "\\end{columns}"))))
627 (defun org-beamer-headline (headline contents info)
628 "Transcode HEADLINE element into Beamer code.
629 CONTENTS is the contents of the headline. INFO is a plist used
630 as a communication channel."
631 (unless (org-element-property :footnote-section-p headline)
632 (let ((level (org-export-get-relative-level headline info))
633 (frame-level (org-beamer--frame-level headline info))
634 (environment (let ((env (org-element-property :BEAMER_ENV headline)))
635 (or (org-string-nw-p env) "block"))))
636 (cond
637 ;; Case 1: Resume frame specified by "BEAMER_ref" property.
638 ((equal environment "againframe")
639 (let ((ref (org-element-property :BEAMER_REF headline)))
640 ;; Reference to frame being resumed is mandatory. Ignore
641 ;; the whole headline if it isn't provided.
642 (when (org-string-nw-p ref)
643 (concat "\\againframe"
644 ;; Overlay specification.
645 (let ((overlay (org-element-property :BEAMER_ACT headline)))
646 (when overlay
647 (org-beamer--normalize-argument
648 overlay
649 (if (string-match "^\\[.*\\]$" overlay) 'defaction
650 'action))))
651 ;; Options.
652 (let ((options (org-element-property :BEAMER_OPT headline)))
653 (when options
654 (org-beamer--normalize-argument options 'option)))
655 ;; Resolve reference provided by "BEAMER_ref"
656 ;; property. This is done by building a minimal fake
657 ;; link and calling the appropriate resolve function,
658 ;; depending on the reference syntax.
659 (let* ((type
660 (progn
661 (string-match "^\\(id:\\|#\\|\\*\\)?\\(.*\\)" ref)
662 (cond
663 ((or (not (match-string 1 ref))
664 (equal (match-string 1 ref) "*")) 'fuzzy)
665 ((equal (match-string 1 ref) "id:") 'id)
666 (t 'custom-id))))
667 (link (list 'link (list :path (match-string 2 ref))))
668 (target (if (eq type 'fuzzy)
669 (org-export-resolve-fuzzy-link link info)
670 (org-export-resolve-id-link link info))))
671 ;; Now use user-defined label provided in TARGET
672 ;; headline, or fallback to standard one.
673 (format "{%s}" (org-beamer--get-label target info)))))))
674 ;; Case 2: Creation of an appendix is requested.
675 ((equal environment "appendix")
676 (concat "\\appendix"
677 (org-element-property :BEAMER_ACT headline)
678 "\n"
679 (make-string (org-element-property :pre-blank headline) ?\n)
680 contents))
681 ;; Case 3: Ignore heading.
682 ((equal environment "ignoreheading")
683 (concat (make-string (org-element-property :pre-blank headline) ?\n)
684 contents))
685 ;; Case 4: HEADLINE is a note.
686 ((member environment '("note" "noteNH"))
687 (format "\\note{%s}"
688 (concat (and (equal environment "note")
689 (concat
690 (org-export-data
691 (org-element-property :title headline) info)
692 "\n"))
693 (org-trim contents))))
694 ;; Case 5: HEADLINE is a frame.
695 ((= level frame-level)
696 (org-beamer--format-frame headline contents info))
697 ;; Case 6: Regular section, extracted from
698 ;; `org-latex-classes'.
699 ((< level frame-level)
700 (org-beamer--format-section headline contents info))
701 ;; Case 7: Otherwise, HEADLINE is a block.
702 (t (org-beamer--format-block headline contents info))))))
705 ;;;; Item
707 (defun org-beamer-item (item contents info)
708 "Transcode an ITEM element into Beamer code.
709 CONTENTS holds the contents of the item. INFO is a plist holding
710 contextual information."
711 (let ((action (let ((first-element (car (org-element-contents item))))
712 (and (eq (org-element-type first-element) 'paragraph)
713 (org-beamer--element-has-overlay-p first-element))))
714 (output (org-export-with-backend 'latex item contents info)))
715 (if (not action) output
716 ;; If the item starts with a paragraph and that paragraph starts
717 ;; with an export snippet specifying an overlay, insert it after
718 ;; \item command.
719 (replace-regexp-in-string "\\\\item" (concat "\\\\item" action) output))))
722 ;;;; Keyword
724 (defun org-beamer-keyword (keyword contents info)
725 "Transcode a KEYWORD element into Beamer code.
726 CONTENTS is nil. INFO is a plist used as a communication
727 channel."
728 (let ((key (org-element-property :key keyword))
729 (value (org-element-property :value keyword)))
730 ;; Handle specifically BEAMER and TOC (headlines only) keywords.
731 ;; Otherwise, fallback to `latex' back-end.
732 (cond
733 ((equal key "BEAMER") value)
734 ((and (equal key "TOC") (string-match "\\<headlines\\>" value))
735 (let ((depth (or (and (string-match "[0-9]+" value)
736 (string-to-number (match-string 0 value)))
737 (plist-get info :with-toc)))
738 (options (and (string-match "\\[.*?\\]" value)
739 (match-string 0 value))))
740 (concat
741 (when (wholenump depth) (format "\\setcounter{tocdepth}{%s}\n" depth))
742 "\\tableofcontents" options)))
743 (t (org-export-with-backend 'latex keyword contents info)))))
746 ;;;; Link
748 (defun org-beamer-link (link contents info)
749 "Transcode a LINK object into Beamer code.
750 CONTENTS is the description part of the link. INFO is a plist
751 used as a communication channel."
752 (let ((type (org-element-property :type link))
753 (path (org-element-property :path link)))
754 ;; Use \hyperlink command for all internal links.
755 (cond
756 ((equal type "radio")
757 (let ((destination (org-export-resolve-radio-link link info)))
758 (when destination
759 (format "\\hyperlink%s{%s}{%s}"
760 (or (org-beamer--element-has-overlay-p link) "")
761 (org-export-solidify-link-text path)
762 (org-export-data (org-element-contents destination) info)))))
763 ((and (member type '("custom-id" "fuzzy" "id"))
764 (let ((destination (if (string= type "fuzzy")
765 (org-export-resolve-fuzzy-link link info)
766 (org-export-resolve-id-link link info))))
767 (case (org-element-type destination)
768 (headline
769 (let ((label
770 (format "sec-%s"
771 (mapconcat
772 'number-to-string
773 (org-export-get-headline-number
774 destination info)
775 "-"))))
776 (if (and (plist-get info :section-numbers) (not contents))
777 (format "\\ref{%s}" label)
778 (format "\\hyperlink%s{%s}{%s}"
779 (or (org-beamer--element-has-overlay-p link) "")
780 label
781 contents))))
782 (target
783 (let ((path (org-export-solidify-link-text path)))
784 (if (not contents) (format "\\ref{%s}" path)
785 (format "\\hyperlink%s{%s}{%s}"
786 (or (org-beamer--element-has-overlay-p link) "")
787 path
788 contents))))))))
789 ;; Otherwise, use `latex' back-end.
790 (t (org-export-with-backend 'latex link contents info)))))
793 ;;;; Plain List
795 ;; Plain lists support `:environment', `:overlay' and `:options'
796 ;; attributes.
798 (defun org-beamer-plain-list (plain-list contents info)
799 "Transcode a PLAIN-LIST element into Beamer code.
800 CONTENTS is the contents of the list. INFO is a plist holding
801 contextual information."
802 (let* ((type (org-element-property :type plain-list))
803 (attributes (org-combine-plists
804 (org-export-read-attribute :attr_latex plain-list)
805 (org-export-read-attribute :attr_beamer plain-list)))
806 (latex-type (let ((env (plist-get attributes :environment)))
807 (cond (env)
808 ((eq type 'ordered) "enumerate")
809 ((eq type 'descriptive) "description")
810 (t "itemize")))))
811 (org-latex--wrap-label
812 plain-list
813 (format "\\begin{%s}%s%s\n%s\\end{%s}"
814 latex-type
815 ;; Default overlay specification, if any.
816 (org-beamer--normalize-argument
817 (or (plist-get attributes :overlay) "")
818 'defaction)
819 ;; Second optional argument depends on the list type.
820 (org-beamer--normalize-argument
821 (or (plist-get attributes :options) "")
822 'option)
823 ;; Eventually insert contents and close environment.
824 contents
825 latex-type))))
828 ;;;; Radio Target
830 (defun org-beamer-radio-target (radio-target text info)
831 "Transcode a RADIO-TARGET object into Beamer code.
832 TEXT is the text of the target. INFO is a plist holding
833 contextual information."
834 (format "\\hypertarget%s{%s}{%s}"
835 (or (org-beamer--element-has-overlay-p radio-target) "")
836 (org-export-solidify-link-text
837 (org-element-property :value radio-target))
838 text))
841 ;;;; Target
843 (defun org-beamer-target (target contents info)
844 "Transcode a TARGET object into Beamer code.
845 CONTENTS is nil. INFO is a plist holding contextual
846 information."
847 (format "\\hypertarget{%s}{}"
848 (org-export-solidify-link-text (org-element-property :value target))))
851 ;;;; Template
853 ;; Template used is similar to the one used in `latex' back-end,
854 ;; excepted for the table of contents and Beamer themes.
856 (defun org-beamer-template (contents info)
857 "Return complete document string after Beamer conversion.
858 CONTENTS is the transcoded contents string. INFO is a plist
859 holding export options."
860 (let ((title (org-export-data (plist-get info :title) info)))
861 (concat
862 ;; 1. Time-stamp.
863 (and (plist-get info :time-stamp-file)
864 (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
865 ;; 2. Document class and packages.
866 (let* ((class (plist-get info :latex-class))
867 (class-options (plist-get info :latex-class-options))
868 (header (nth 1 (assoc class org-latex-classes)))
869 (document-class-string
870 (and (stringp header)
871 (if (not class-options) header
872 (replace-regexp-in-string
873 "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
874 class-options header t nil 1)))))
875 (if (not document-class-string)
876 (user-error "Unknown LaTeX class `%s'" class)
877 (org-latex-guess-babel-language
878 (org-latex-guess-inputenc
879 (org-element-normalize-string
880 (org-splice-latex-header
881 document-class-string
882 org-latex-default-packages-alist
883 org-latex-packages-alist nil
884 (concat (org-element-normalize-string
885 (plist-get info :latex-header))
886 (org-element-normalize-string
887 (plist-get info :latex-header-extra))
888 (plist-get info :beamer-header-extra)))))
889 info)))
890 ;; 3. Insert themes.
891 (let ((format-theme
892 (function
893 (lambda (prop command)
894 (let ((theme (plist-get info prop)))
895 (when theme
896 (concat command
897 (if (not (string-match "\\[.*\\]" theme))
898 (format "{%s}\n" theme)
899 (format "%s{%s}\n"
900 (match-string 0 theme)
901 (org-trim
902 (replace-match "" nil nil theme)))))))))))
903 (mapconcat (lambda (args) (apply format-theme args))
904 '((:beamer-theme "\\usetheme")
905 (:beamer-color-theme "\\usecolortheme")
906 (:beamer-font-theme "\\usefonttheme")
907 (:beamer-inner-theme "\\useinnertheme")
908 (:beamer-outer-theme "\\useoutertheme"))
909 ""))
910 ;; 4. Possibly limit depth for headline numbering.
911 (let ((sec-num (plist-get info :section-numbers)))
912 (when (integerp sec-num)
913 (format "\\setcounter{secnumdepth}{%d}\n" sec-num)))
914 ;; 5. Author.
915 (let ((author (and (plist-get info :with-author)
916 (let ((auth (plist-get info :author)))
917 (and auth (org-export-data auth info)))))
918 (email (and (plist-get info :with-email)
919 (org-export-data (plist-get info :email) info))))
920 (cond ((and author email (not (string= "" email)))
921 (format "\\author{%s\\thanks{%s}}\n" author email))
922 (author (format "\\author{%s}\n" author))
923 (t "\\author{}\n")))
924 ;; 6. Date.
925 (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
926 (format "\\date{%s}\n" (org-export-data date info)))
927 ;; 7. Title
928 (format "\\title{%s}\n" title)
929 ;; 8. Hyperref options.
930 (when (plist-get info :latex-hyperref-p)
931 (format "\\hypersetup{\n pdfkeywords={%s},\n pdfsubject={%s},\n pdfcreator={%s}}\n"
932 (or (plist-get info :keywords) "")
933 (or (plist-get info :description) "")
934 (if (not (plist-get info :with-creator)) ""
935 (plist-get info :creator))))
936 ;; 9. Document start.
937 "\\begin{document}\n\n"
938 ;; 10. Title command.
939 (org-element-normalize-string
940 (cond ((string= "" title) nil)
941 ((not (stringp org-latex-title-command)) nil)
942 ((string-match "\\(?:[^%]\\|^\\)%s"
943 org-latex-title-command)
944 (format org-latex-title-command title))
945 (t org-latex-title-command)))
946 ;; 11. Table of contents.
947 (let ((depth (plist-get info :with-toc)))
948 (when depth
949 (concat
950 (format "\\begin{frame}%s{%s}\n"
951 (org-beamer--normalize-argument
952 org-beamer-outline-frame-options 'option)
953 org-beamer-outline-frame-title)
954 (when (wholenump depth)
955 (format "\\setcounter{tocdepth}{%d}\n" depth))
956 "\\tableofcontents\n"
957 "\\end{frame}\n\n")))
958 ;; 12. Document's body.
959 contents
960 ;; 13. Creator.
961 (let ((creator-info (plist-get info :with-creator)))
962 (cond
963 ((not creator-info) "")
964 ((eq creator-info 'comment)
965 (format "%% %s\n" (plist-get info :creator)))
966 (t (concat (plist-get info :creator) "\n"))))
967 ;; 14. Document end.
968 "\\end{document}")))
972 ;;; Minor Mode
975 (defvar org-beamer-mode-map (make-sparse-keymap)
976 "The keymap for `org-beamer-mode'.")
977 (define-key org-beamer-mode-map "\C-c\C-b" 'org-beamer-select-environment)
979 ;;;###autoload
980 (define-minor-mode org-beamer-mode
981 "Support for editing Beamer oriented Org mode files."
982 nil " Bm" 'org-beamer-mode-map)
984 (when (fboundp 'font-lock-add-keywords)
985 (font-lock-add-keywords
986 'org-mode
987 '((":\\(B_[a-z]+\\|BMCOL\\):" 1 'org-beamer-tag prepend))
988 'prepend))
990 (defface org-beamer-tag '((t (:box (:line-width 1 :color grey40))))
991 "The special face for beamer tags."
992 :group 'org-export-beamer)
994 (defun org-beamer-property-changed (property value)
995 "Track the BEAMER_env property with tags.
996 PROPERTY is the name of the modified property. VALUE is its new
997 value."
998 (cond
999 ((equal property "BEAMER_env")
1000 (save-excursion
1001 (org-back-to-heading t)
1002 ;; Filter out Beamer-related tags and install environment tag.
1003 (let ((tags (org-remove-if (lambda (x) (string-match "^B_" x))
1004 (org-get-tags)))
1005 (env-tag (and (org-string-nw-p value) (concat "B_" value))))
1006 (org-set-tags-to (if env-tag (cons env-tag tags) tags))
1007 (when env-tag (org-toggle-tag env-tag 'on)))))
1008 ((equal property "BEAMER_col")
1009 (org-toggle-tag "BMCOL" (if (org-string-nw-p value) 'on 'off)))))
1011 (add-hook 'org-property-changed-functions 'org-beamer-property-changed)
1013 (defun org-beamer-allowed-property-values (property)
1014 "Supply allowed values for PROPERTY."
1015 (cond
1016 ((and (equal property "BEAMER_env")
1017 (not (org-entry-get nil (concat property "_ALL") 'inherit)))
1018 ;; If no allowed values for BEAMER_env have been defined,
1019 ;; supply all defined environments
1020 (mapcar 'car (append org-beamer-environments-special
1021 org-beamer-environments-extra
1022 org-beamer-environments-default)))
1023 ((and (equal property "BEAMER_col")
1024 (not (org-entry-get nil (concat property "_ALL") 'inherit)))
1025 ;; If no allowed values for BEAMER_col have been defined,
1026 ;; supply some
1027 (org-split-string org-beamer-column-widths " "))))
1029 (add-hook 'org-property-allowed-value-functions
1030 'org-beamer-allowed-property-values)
1034 ;;; Commands
1036 ;;;###autoload
1037 (defun org-beamer-export-as-latex
1038 (&optional async subtreep visible-only body-only ext-plist)
1039 "Export current buffer as a Beamer buffer.
1041 If narrowing is active in the current buffer, only export its
1042 narrowed part.
1044 If a region is active, export that region.
1046 A non-nil optional argument ASYNC means the process should happen
1047 asynchronously. The resulting buffer should be accessible
1048 through the `org-export-stack' interface.
1050 When optional argument SUBTREEP is non-nil, export the sub-tree
1051 at point, extracting information from the headline properties
1052 first.
1054 When optional argument VISIBLE-ONLY is non-nil, don't export
1055 contents of hidden elements.
1057 When optional argument BODY-ONLY is non-nil, only write code
1058 between \"\\begin{document}\" and \"\\end{document}\".
1060 EXT-PLIST, when provided, is a property list with external
1061 parameters overriding Org default settings, but still inferior to
1062 file-local settings.
1064 Export is done in a buffer named \"*Org BEAMER Export*\", which
1065 will be displayed when `org-export-show-temporary-export-buffer'
1066 is non-nil."
1067 (interactive)
1068 (org-export-to-buffer 'beamer "*Org BEAMER Export*"
1069 async subtreep visible-only body-only ext-plist (lambda () (LaTeX-mode))))
1071 ;;;###autoload
1072 (defun org-beamer-export-to-latex
1073 (&optional async subtreep visible-only body-only ext-plist)
1074 "Export current buffer as a Beamer presentation (tex).
1076 If narrowing is active in the current buffer, only export its
1077 narrowed part.
1079 If a region is active, export that region.
1081 A non-nil optional argument ASYNC means the process should happen
1082 asynchronously. The resulting file should be accessible through
1083 the `org-export-stack' interface.
1085 When optional argument SUBTREEP is non-nil, export the sub-tree
1086 at point, extracting information from the headline properties
1087 first.
1089 When optional argument VISIBLE-ONLY is non-nil, don't export
1090 contents of hidden elements.
1092 When optional argument BODY-ONLY is non-nil, only write code
1093 between \"\\begin{document}\" and \"\\end{document}\".
1095 EXT-PLIST, when provided, is a property list with external
1096 parameters overriding Org default settings, but still inferior to
1097 file-local settings.
1099 Return output file's name."
1100 (interactive)
1101 (let ((file (org-export-output-file-name ".tex" subtreep)))
1102 (org-export-to-file 'beamer file
1103 async subtreep visible-only body-only ext-plist)))
1105 ;;;###autoload
1106 (defun org-beamer-export-to-pdf
1107 (&optional async subtreep visible-only body-only ext-plist)
1108 "Export current buffer as a Beamer presentation (PDF).
1110 If narrowing is active in the current buffer, only export its
1111 narrowed part.
1113 If a region is active, export that region.
1115 A non-nil optional argument ASYNC means the process should happen
1116 asynchronously. The resulting file should be accessible through
1117 the `org-export-stack' interface.
1119 When optional argument SUBTREEP is non-nil, export the sub-tree
1120 at point, extracting information from the headline properties
1121 first.
1123 When optional argument VISIBLE-ONLY is non-nil, don't export
1124 contents of hidden elements.
1126 When optional argument BODY-ONLY is non-nil, only write code
1127 between \"\\begin{document}\" and \"\\end{document}\".
1129 EXT-PLIST, when provided, is a property list with external
1130 parameters overriding Org default settings, but still inferior to
1131 file-local settings.
1133 Return PDF file's name."
1134 (interactive)
1135 (let ((file (org-export-output-file-name ".tex" subtreep)))
1136 (org-export-to-file 'beamer file
1137 async subtreep visible-only body-only ext-plist
1138 (lambda (file) (org-latex-compile file)))))
1140 ;;;###autoload
1141 (defun org-beamer-select-environment ()
1142 "Select the environment to be used by beamer for this entry.
1143 While this uses (for convenience) a tag selection interface, the
1144 result of this command will be that the BEAMER_env *property* of
1145 the entry is set.
1147 In addition to this, the command will also set a tag as a visual
1148 aid, but the tag does not have any semantic meaning."
1149 (interactive)
1150 ;; Make sure `org-beamer-environments-special' has a higher
1151 ;; priority than `org-beamer-environments-extra'.
1152 (let* ((envs (append org-beamer-environments-special
1153 org-beamer-environments-extra
1154 org-beamer-environments-default))
1155 (org-tag-alist
1156 (append '((:startgroup))
1157 (mapcar (lambda (e) (cons (concat "B_" (car e))
1158 (string-to-char (nth 1 e))))
1159 envs)
1160 '((:endgroup))
1161 '(("BMCOL" . ?|))))
1162 (org-fast-tag-selection-single-key t))
1163 (org-set-tags)
1164 (let ((tags (or (ignore-errors (org-get-tags-string)) "")))
1165 (cond
1166 ;; For a column, automatically ask for its width.
1167 ((eq org-last-tag-selection-key ?|)
1168 (if (string-match ":BMCOL:" tags)
1169 (org-set-property "BEAMER_col" (read-string "Column width: "))
1170 (org-delete-property "BEAMER_col")))
1171 ;; For an "againframe" section, automatically ask for reference
1172 ;; to resumed frame and overlay specifications.
1173 ((eq org-last-tag-selection-key ?A)
1174 (if (equal (org-entry-get nil "BEAMER_env") "againframe")
1175 (progn (org-entry-delete nil "BEAMER_env")
1176 (org-entry-delete nil "BEAMER_ref")
1177 (org-entry-delete nil "BEAMER_act"))
1178 (org-entry-put nil "BEAMER_env" "againframe")
1179 (org-set-property
1180 "BEAMER_ref"
1181 (read-string "Frame reference (*Title, #custom-id, id:...): "))
1182 (org-set-property "BEAMER_act"
1183 (read-string "Overlay specification: "))))
1184 ((string-match (concat ":B_\\(" (mapconcat 'car envs "\\|") "\\):") tags)
1185 (org-entry-put nil "BEAMER_env" (match-string 1 tags)))
1186 (t (org-entry-delete nil "BEAMER_env"))))))
1188 ;;;###autoload
1189 (defun org-beamer-insert-options-template (&optional kind)
1190 "Insert a settings template, to make sure users do this right."
1191 (interactive (progn
1192 (message "Current [s]ubtree or [g]lobal?")
1193 (if (eq (read-char-exclusive) ?g) (list 'global)
1194 (list 'subtree))))
1195 (if (eq kind 'subtree)
1196 (progn
1197 (org-back-to-heading t)
1198 (org-reveal)
1199 (org-entry-put nil "EXPORT_LaTeX_CLASS" "beamer")
1200 (org-entry-put nil "EXPORT_LaTeX_CLASS_OPTIONS" "[presentation]")
1201 (org-entry-put nil "EXPORT_FILE_NAME" "presentation.pdf")
1202 (when org-beamer-column-view-format
1203 (org-entry-put nil "COLUMNS" org-beamer-column-view-format))
1204 (org-entry-put nil "BEAMER_col_ALL" org-beamer-column-widths))
1205 (insert "#+LaTeX_CLASS: beamer\n")
1206 (insert "#+LaTeX_CLASS_OPTIONS: [presentation]\n")
1207 (when org-beamer-theme (insert "#+BEAMER_THEME: " org-beamer-theme "\n"))
1208 (when org-beamer-column-view-format
1209 (insert "#+COLUMNS: " org-beamer-column-view-format "\n"))
1210 (insert "#+PROPERTY: BEAMER_col_ALL " org-beamer-column-widths "\n")))
1212 ;;;###autoload
1213 (defun org-beamer-publish-to-latex (plist filename pub-dir)
1214 "Publish an Org file to a Beamer presentation (LaTeX).
1216 FILENAME is the filename of the Org file to be published. PLIST
1217 is the property list for the given project. PUB-DIR is the
1218 publishing directory.
1220 Return output file name."
1221 (org-publish-org-to 'beamer filename ".tex" plist pub-dir))
1223 ;;;###autoload
1224 (defun org-beamer-publish-to-pdf (plist filename pub-dir)
1225 "Publish an Org file to a Beamer presentation (PDF, via LaTeX).
1227 FILENAME is the filename of the Org file to be published. PLIST
1228 is the property list for the given project. PUB-DIR is the
1229 publishing directory.
1231 Return output file name."
1232 ;; Unlike to `org-beamer-publish-to-latex', PDF file is generated in
1233 ;; working directory and then moved to publishing directory.
1234 (org-publish-attachment
1235 plist
1236 (org-latex-compile (org-publish-org-to 'beamer filename ".tex" plist))
1237 pub-dir))
1240 (provide 'ox-beamer)
1242 ;; Local variables:
1243 ;; generated-autoload-file: "org-loaddefs.el"
1244 ;; End:
1246 ;;; ox-beamer.el ends here