summaryrefslogtreecommitdiff
path: root/lisp/ox-beamer.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ox-beamer.el')
-rw-r--r--lisp/ox-beamer.el207
1 files changed, 107 insertions, 100 deletions
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index 5ab805d..3119bd4 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -1,6 +1,6 @@
;;; ox-beamer.el --- Beamer Back-End for Org Export Engine
-;; Copyright (C) 2007-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2015 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
;; Nicolas Goaziou <n.goaziou AT gmail DOT com>
@@ -105,7 +105,9 @@ key Selection key for `org-beamer-select-environment'
open The opening template for the environment, with the following escapes
%a the action/overlay specification
%A the default action/overlay specification
- %o the options argument of the template
+ %R the raw BEAMER_act value
+ %o the options argument, with square brackets
+ %O the raw BEAMER_opt value
%h the headline text
%r the raw headline text (i.e. without any processing)
%H if there is headline text, that raw text in {} braces
@@ -133,6 +135,15 @@ You might want to put e.g. \"allowframebreaks=0.9\" here."
:type '(string :tag "Outline frame options"))
+(defcustom org-beamer-subtitle-format "\\subtitle{%s}"
+ "Format string used for transcoded subtitle.
+The format string should have at most one \"%s\"-expression,
+which is replaced with the subtitle."
+ :group 'org-export-beamer
+ :version "25.1"
+ :package-version '(Org . "8.3")
+ :type '(string :tag "Format string"))
+
;;; Internal Variables
@@ -231,15 +242,20 @@ Return overlay specification, as a string, or nil."
(if a (org-beamer-export-to-pdf t s v b)
(org-open-file (org-beamer-export-to-pdf nil s v b)))))))
:options-alist
- '((:beamer-theme "BEAMER_THEME" nil org-beamer-theme)
+ '((:headline-levels nil "H" org-beamer-frame-level)
+ (:latex-class "LATEX_CLASS" nil "beamer" t)
+ (:beamer-subtitle-format nil nil org-beamer-subtitle-format)
+ (:beamer-column-view-format "COLUMNS" nil org-beamer-column-view-format)
+ (:beamer-theme "BEAMER_THEME" nil org-beamer-theme)
(:beamer-color-theme "BEAMER_COLOR_THEME" nil nil t)
(:beamer-font-theme "BEAMER_FONT_THEME" nil nil t)
(:beamer-inner-theme "BEAMER_INNER_THEME" nil nil t)
(:beamer-outer-theme "BEAMER_OUTER_THEME" nil nil t)
- (:beamer-header-extra "BEAMER_HEADER" nil nil newline)
- ;; Modify existing properties.
- (:headline-levels nil "H" org-beamer-frame-level)
- (:latex-class "LATEX_CLASS" nil "beamer" t))
+ (:beamer-header "BEAMER_HEADER" nil nil newline)
+ (:beamer-environments-extra nil nil org-beamer-environments-extra)
+ (:beamer-frame-default-options nil nil org-beamer-frame-default-options)
+ (:beamer-outline-frame-options nil nil org-beamer-outline-frame-options)
+ (:beamer-outline-frame-title nil nil org-beamer-outline-frame-title))
:translate-alist '((bold . org-beamer-bold)
(export-block . org-beamer-export-block)
(export-snippet . org-beamer-export-snippet)
@@ -318,13 +334,10 @@ The value is either the label specified in \"BEAMER_opt\"
property, or a fallback value built from headline's number. This
function assumes HEADLINE will be treated as a frame."
(let ((opt (org-element-property :BEAMER_OPT headline)))
- (if (and (org-string-nw-p opt)
+ (if (and (stringp opt)
(string-match "\\(?:^\\|,\\)label=\\(.*?\\)\\(?:$\\|,\\)" opt))
(match-string 1 opt)
- (format "sec-%s"
- (mapconcat 'number-to-string
- (org-export-get-headline-number headline info)
- "-")))))
+ (format "{sec:%s}" (org-export-get-reference headline info)))))
(defun org-beamer--frame-level (headline info)
"Return frame level in subtree containing HEADLINE.
@@ -333,12 +346,10 @@ INFO is a plist used as a communication channel."
;; 1. Look for "frame" environment in parents, starting from the
;; farthest.
(catch 'exit
- (mapc (lambda (parent)
- (let ((env (org-element-property :BEAMER_ENV parent)))
- (when (and env (member-ignore-case env '("frame" "fullframe")))
- (throw 'exit (org-export-get-relative-level parent info)))))
- (nreverse (org-export-get-genealogy headline)))
- nil)
+ (dolist (parent (nreverse (org-element-lineage headline)))
+ (let ((env (org-element-property :BEAMER_ENV parent)))
+ (when (and env (member-ignore-case env '("frame" "fullframe")))
+ (throw 'exit (org-export-get-relative-level parent info))))))
;; 2. Look for "frame" environment in HEADLINE.
(let ((env (org-element-property :BEAMER_ENV headline)))
(and env (member-ignore-case env '("frame" "fullframe"))
@@ -413,7 +424,8 @@ used as a communication channel."
;; Collect options from default value and headline's
;; properties. Also add a label for links.
(append
- (org-split-string org-beamer-frame-default-options ",")
+ (org-split-string
+ (plist-get info :beamer-frame-default-options) ",")
(and beamer-opt
(org-split-string
;; Remove square brackets if user provided
@@ -422,9 +434,12 @@ used as a communication channel."
(match-string 1 beamer-opt))
","))
;; Provide an automatic label for the frame
- ;; unless the user specified one.
+ ;; unless the user specified one. Also refrain
+ ;; from labeling `allowframebreaks' frames; this
+ ;; is not allowed by beamer.
(unless (and beamer-opt
- (string-match "\\(^\\|,\\)label=" beamer-opt))
+ (or (string-match "\\(^\\|,\\)label=" beamer-opt)
+ (string-match "allowframebreaks" beamer-opt)))
(list
(format "label=%s"
(org-beamer--get-label headline info)))))))
@@ -475,14 +490,15 @@ used as a communication channel."
(env-format
(cond ((member environment '("column" "columns")) nil)
((assoc environment
- (append org-beamer-environments-extra
+ (append (plist-get info :beamer-environments-extra)
org-beamer-environments-default)))
(t (user-error "Wrong block type at a headline named \"%s\""
raw-title))))
(title (org-export-data (org-element-property :title headline) info))
- (options (let ((options (org-element-property :BEAMER_OPT headline)))
- (if (not options) ""
- (org-beamer--normalize-argument options 'option))))
+ (raw-options (org-element-property :BEAMER_OPT headline))
+ (options (if raw-options
+ (org-beamer--normalize-argument raw-options 'option)
+ ""))
;; Start a "columns" environment when explicitly requested or
;; when there is no previous headline or the previous
;; headline do not have a BEAMER_column property.
@@ -521,7 +537,7 @@ used as a communication channel."
;; One can specify placement for column only when
;; HEADLINE stands for a column on its own.
(if (equal environment "column") options "")
- (format "%s\\textwidth" column-width)))
+ (format "%s\\columnwidth" column-width)))
;; Block's opening string.
(when (nth 2 env-format)
(concat
@@ -534,15 +550,18 @@ used as a communication channel."
;; overlay specification and the default one is nil.
(let ((action (org-element-property :BEAMER_ACT headline)))
(cond
- ((not action) (list (cons "a" "") (cons "A" "")))
+ ((not action) (list (cons "a" "") (cons "A" "") (cons "R" "")))
((string-match "\\`\\[.*\\]\\'" action)
(list
(cons "A" (org-beamer--normalize-argument action 'defaction))
- (cons "a" "")))
+ (cons "a" "")
+ (cons "R" action)))
(t
(list (cons "a" (org-beamer--normalize-argument action 'action))
- (cons "A" "")))))
+ (cons "A" "")
+ (cons "R" action)))))
(list (cons "o" options)
+ (cons "O" (or raw-options ""))
(cons "h" title)
(cons "r" raw-title)
(cons "H" (if (equal raw-title "") ""
@@ -640,15 +659,27 @@ as a communication channel."
"Transcode an ITEM element into Beamer code.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
- (let ((action (let ((first-element (car (org-element-contents item))))
- (and (eq (org-element-type first-element) 'paragraph)
- (org-beamer--element-has-overlay-p first-element))))
- (output (org-export-with-backend 'latex item contents info)))
- (if (or (not action) (not (string-match "\\\\item" output))) output
- ;; If the item starts with a paragraph and that paragraph starts
- ;; with an export snippet specifying an overlay, insert it after
- ;; \item command.
- (replace-match (concat "\\\\item" action) nil nil output))))
+ (org-export-with-backend
+ ;; Delegate item export to `latex'. However, we use `beamer'
+ ;; transcoders for objects in the description tag.
+ (org-export-create-backend
+ :parent 'beamer
+ :transcoders
+ (list
+ (cons
+ 'item
+ (lambda (item c i)
+ (let ((action
+ (let ((first (car (org-element-contents item))))
+ (and (eq (org-element-type first) 'paragraph)
+ (org-beamer--element-has-overlay-p first))))
+ (output (org-latex-item item contents info)))
+ (if (not (and action (string-match "\\\\item" output))) output
+ ;; If the item starts with a paragraph and that paragraph
+ ;; starts with an export snippet specifying an overlay,
+ ;; append it to the \item command.
+ (replace-match (concat "\\\\item" action) nil nil output)))))))
+ item contents info))
;;;; Keyword
@@ -683,15 +714,16 @@ CONTENTS is the description part of the link. INFO is a plist
used as a communication channel."
(let ((type (org-element-property :type link))
(path (org-element-property :path link)))
- ;; Use \hyperlink command for all internal links.
(cond
+ ;; Link type is handled by a special function.
+ ((org-export-custom-protocol-maybe link contents 'beamer))
+ ;; Use \hyperlink command for all internal links.
((equal type "radio")
(let ((destination (org-export-resolve-radio-link link info)))
(if (not destination) contents
(format "\\hyperlink%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p link) "")
- (org-export-solidify-link-text
- (org-element-property :value destination))
+ (org-export-get-reference destination info)
contents))))
((and (member type '("custom-id" "fuzzy" "id"))
(let ((destination (if (string= type "fuzzy")
@@ -713,11 +745,11 @@ used as a communication channel."
label
contents))))
(target
- (let ((path (org-export-solidify-link-text path)))
- (if (not contents) (format "\\ref{%s}" path)
+ (let ((ref (org-export-get-reference destination info)))
+ (if (not contents) (format "\\ref{%s}" ref)
(format "\\hyperlink%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p link) "")
- path
+ ref
contents))))))))
;; Otherwise, use `latex' back-end.
(t (org-export-with-backend 'latex link contents info)))))
@@ -755,7 +787,8 @@ contextual information."
'option)
;; Eventually insert contents and close environment.
contents
- latex-type))))
+ latex-type)
+ info)))
;;;; Radio Target
@@ -766,8 +799,7 @@ TEXT is the text of the target. INFO is a plist holding
contextual information."
(format "\\hypertarget%s{%s}{%s}"
(or (org-beamer--element-has-overlay-p radio-target) "")
- (org-export-solidify-link-text
- (org-element-property :value radio-target))
+ (org-export-get-reference radio-target info)
text))
@@ -777,8 +809,7 @@ contextual information."
"Transcode a TARGET object into Beamer code.
CONTENTS is nil. INFO is a plist holding contextual
information."
- (format "\\hypertarget{%s}{}"
- (org-export-solidify-link-text (org-element-property :value target))))
+ (format "\\label{%s}" (org-export-get-reference target info)))
;;;; Template
@@ -790,7 +821,8 @@ information."
"Return complete document string after Beamer conversion.
CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
- (let ((title (org-export-data (plist-get info :title) info)))
+ (let ((title (org-export-data (plist-get info :title) info))
+ (subtitle (org-export-data (plist-get info :subtitle) info)))
(concat
;; 1. Time-stamp.
(and (plist-get info :time-stamp-file)
@@ -817,8 +849,7 @@ holding export options."
(concat (org-element-normalize-string
(plist-get info :latex-header))
(org-element-normalize-string
- (plist-get info :latex-header-extra))
- (plist-get info :beamer-header-extra)))))
+ (plist-get info :latex-header-extra))))))
info)))
;; 3. Insert themes.
(let ((format-theme
@@ -852,52 +883,52 @@ holding export options."
(org-export-data (plist-get info :email) info))))
(cond ((and author email (not (string= "" email)))
(format "\\author{%s\\thanks{%s}}\n" author email))
- (author (format "\\author{%s}\n" author))
- (t "\\author{}\n")))
+ ((or author email) (format "\\author{%s}\n" (or author email)))))
;; 6. Date.
(let ((date (and (plist-get info :with-date) (org-export-get-date info))))
(format "\\date{%s}\n" (org-export-data date info)))
;; 7. Title
(format "\\title{%s}\n" title)
- ;; 8. Hyperref options.
- (when (plist-get info :latex-hyperref-p)
- (format "\\hypersetup{\n pdfkeywords={%s},\n pdfsubject={%s},\n pdfcreator={%s}}\n"
- (or (plist-get info :keywords) "")
- (or (plist-get info :description) "")
- (if (not (plist-get info :with-creator)) ""
- (plist-get info :creator))))
- ;; 9. Document start.
+ (when (org-string-nw-p subtitle)
+ (concat (format (plist-get info :beamer-subtitle-format) subtitle) "\n"))
+ ;; 8. Beamer-header
+ (let ((beamer-header (plist-get info :beamer-header)))
+ (when beamer-header
+ (format "%s\n" (plist-get info :beamer-header))))
+ ;; 9. Hyperref options.
+ (let ((template (plist-get info :latex-hyperref-template)))
+ (and (stringp template)
+ (format-spec template (org-latex--format-spec info))))
+ ;; 10. Document start.
"\\begin{document}\n\n"
- ;; 10. Title command.
+ ;; 11. Title command.
(org-element-normalize-string
- (cond ((string= "" title) nil)
+ (cond ((not (plist-get info :with-title)) nil)
+ ((string= "" title) nil)
((not (stringp org-latex-title-command)) nil)
((string-match "\\(?:[^%]\\|^\\)%s"
org-latex-title-command)
(format org-latex-title-command title))
(t org-latex-title-command)))
- ;; 11. Table of contents.
+ ;; 12. Table of contents.
(let ((depth (plist-get info :with-toc)))
(when depth
(concat
(format "\\begin{frame}%s{%s}\n"
(org-beamer--normalize-argument
- org-beamer-outline-frame-options 'option)
- org-beamer-outline-frame-title)
+ (plist-get info :beamer-outline-frame-options) 'option)
+ (plist-get info :beamer-outline-frame-title))
(when (wholenump depth)
(format "\\setcounter{tocdepth}{%d}\n" depth))
"\\tableofcontents\n"
"\\end{frame}\n\n")))
- ;; 12. Document's body.
+ ;; 13. Document's body.
contents
- ;; 13. Creator.
- (let ((creator-info (plist-get info :with-creator)))
- (cond
- ((not creator-info) "")
- ((eq creator-info 'comment)
- (format "%% %s\n" (plist-get info :creator)))
- (t (concat (plist-get info :creator) "\n"))))
- ;; 14. Document end.
+ ;; 14. Creator.
+ (if (plist-get info :with-creator)
+ (concat (plist-get info :creator) "\n")
+ "")
+ ;; 15. Document end.
"\\end{document}")))
@@ -1121,30 +1152,6 @@ aid, but the tag does not have any semantic meaning."
(t (org-entry-delete nil "BEAMER_env"))))))
;;;###autoload
-(defun org-beamer-insert-options-template (&optional kind)
- "Insert a settings template, to make sure users do this right."
- (interactive (progn
- (message "Current [s]ubtree or [g]lobal?")
- (if (eq (read-char-exclusive) ?g) (list 'global)
- (list 'subtree))))
- (if (eq kind 'subtree)
- (progn
- (org-back-to-heading t)
- (org-reveal)
- (org-entry-put nil "EXPORT_LaTeX_CLASS" "beamer")
- (org-entry-put nil "EXPORT_LaTeX_CLASS_OPTIONS" "[presentation]")
- (org-entry-put nil "EXPORT_FILE_NAME" "presentation.pdf")
- (when org-beamer-column-view-format
- (org-entry-put nil "COLUMNS" org-beamer-column-view-format))
- (org-entry-put nil "BEAMER_col_ALL" org-beamer-column-widths))
- (insert "#+LaTeX_CLASS: beamer\n")
- (insert "#+LaTeX_CLASS_OPTIONS: [presentation]\n")
- (when org-beamer-theme (insert "#+BEAMER_THEME: " org-beamer-theme "\n"))
- (when org-beamer-column-view-format
- (insert "#+COLUMNS: " org-beamer-column-view-format "\n"))
- (insert "#+PROPERTY: BEAMER_col_ALL " org-beamer-column-widths "\n")))
-
-;;;###autoload
(defun org-beamer-publish-to-latex (plist filename pub-dir)
"Publish an Org file to a Beamer presentation (LaTeX).