ox-beamer.el 42 KB

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