ox-beamer.el 42 KB

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