ox-beamer.el 43 KB

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