org-export-latex.el 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612
  1. ;;; org-export-latex.el --- LaTeX exporter for org-mode
  2. ;;
  3. ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
  4. ;;
  5. ;; Emacs Lisp Archive Entry
  6. ;; Filename: org-export-latex.el
  7. ;; Version: 6.19d
  8. ;; Author: Bastien Guerry <bzg AT altern DOT org>
  9. ;; Maintainer: Bastien Guerry <bzg AT altern DOT org>
  10. ;; Keywords: org, wp, tex
  11. ;; Description: Converts an org-mode buffer into LaTeX
  12. ;; URL: http://www.cognition.ens.fr/~guerry/u/org-export-latex.el
  13. ;; This file is part of GNU Emacs.
  14. ;; GNU Emacs is free software: you can redistribute it and/or modify
  15. ;; it under the terms of the GNU General Public License as published by
  16. ;; the Free Software Foundation, either version 3 of the License, or
  17. ;; (at your option) any later version.
  18. ;; GNU Emacs is distributed in the hope that it will be useful,
  19. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;; GNU General Public License for more details.
  22. ;; You should have received a copy of the GNU General Public License
  23. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  24. ;;; Commentary:
  25. ;;
  26. ;; This library implements a LaTeX exporter for org-mode.
  27. ;;
  28. ;; Put this file into your load-path and the following into your ~/.emacs:
  29. ;; (require 'org-export-latex)
  30. ;;
  31. ;; The interactive functions are similar to those of the HTML exporter:
  32. ;;
  33. ;; M-x `org-export-as-latex'
  34. ;; M-x `org-export-as-pdf'
  35. ;; M-x `org-export-as-pdf-and-open'
  36. ;; M-x `org-export-as-latex-batch'
  37. ;; M-x `org-export-as-latex-to-buffer'
  38. ;; M-x `org-export-region-as-latex'
  39. ;; M-x `org-replace-region-by-latex'
  40. ;;
  41. ;;; Code:
  42. (eval-when-compile
  43. (require 'cl))
  44. (require 'footnote)
  45. (require 'org)
  46. (require 'org-exp)
  47. ;;; Variables:
  48. (defvar org-export-latex-class nil)
  49. (defvar org-export-latex-header nil)
  50. (defvar org-export-latex-append-header nil)
  51. (defvar org-export-latex-options-plist nil)
  52. (defvar org-export-latex-todo-keywords-1 nil)
  53. (defvar org-export-latex-all-targets-re nil)
  54. (defvar org-export-latex-add-level 0)
  55. (defvar org-export-latex-sectioning "")
  56. (defvar org-export-latex-sectioning-depth 0)
  57. (defvar org-export-latex-special-keyword-regexp
  58. (concat "\\<\\(" org-scheduled-string "\\|"
  59. org-deadline-string "\\|"
  60. org-closed-string"\\)")
  61. "Regexp matching special time planning keywords plus the time after it.")
  62. (defvar latexp) ; dynamically scoped from org.el
  63. (defvar re-quote) ; dynamically scoped from org.el
  64. (defvar commentsp) ; dynamically scoped from org.el
  65. ;;; User variables:
  66. (defgroup org-export-latex nil
  67. "Options for exporting Org-mode files to LaTeX."
  68. :tag "Org Export LaTeX"
  69. :group 'org-export)
  70. (defcustom org-export-latex-default-class "article"
  71. "The default LaTeX class."
  72. :group 'org-export-latex
  73. :type '(string :tag "LaTeX class"))
  74. (defcustom org-export-latex-classes
  75. '(("article"
  76. "\\documentclass[11pt,a4paper]{article}
  77. \\usepackage[utf8]{inputenc}
  78. \\usepackage[T1]{fontenc}
  79. \\usepackage{graphicx}
  80. \\usepackage{longtable}
  81. \\usepackage{hyperref}"
  82. ("\\section{%s}" . "\\section*{%s}")
  83. ("\\subsection{%s}" . "\\subsection*{%s}")
  84. ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
  85. ("\\paragraph{%s}" . "\\paragraph*{%s}")
  86. ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
  87. ("report"
  88. "\\documentclass[11pt,a4paper]{report}
  89. \\usepackage[utf8]{inputenc}
  90. \\usepackage[T1]{fontenc}
  91. \\usepackage{graphicx}
  92. \\usepackage{longtable}
  93. \\usepackage{hyperref}"
  94. ("\\part{%s}" . "\\part*{%s}")
  95. ("\\chapter{%s}" . "\\chapter*{%s}")
  96. ("\\section{%s}" . "\\section*{%s}")
  97. ("\\subsection{%s}" . "\\subsection*{%s}")
  98. ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
  99. ("book"
  100. "\\documentclass[11pt,a4paper]{book}
  101. \\usepackage[utf8]{inputenc}
  102. \\usepackage[T1]{fontenc}
  103. \\usepackage{graphicx}
  104. \\usepackage{longtable}
  105. \\usepackage{hyperref}"
  106. ("\\part{%s}" . "\\part*{%s}")
  107. ("\\chapter{%s}" . "\\chapter*{%s}")
  108. ("\\section{%s}" . "\\section*{%s}")
  109. ("\\subsection{%s}" . "\\subsection*{%s}")
  110. ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
  111. "Alist of LaTeX classes and associated header and structure.
  112. If #+LaTeX_CLASS is set in the buffer, use its value and the
  113. associated information. Here is the structure of each cell:
  114. \(class-name
  115. header-string
  116. (numbered-section . unnumbered-section\)
  117. ...\)
  118. A %s formatter is mandatory in each section string and will be
  119. replaced by the title of the section.
  120. Instead of a cons cell (numbered . unnumbered), you can also provide a list
  121. of 2-4 elements,
  122. (numbered-open numbered-close)
  123. or
  124. (numbered-open numbered-close unnumbered-open unnumbered-close)
  125. providing opening and closing strings for an environment that should
  126. represent the document section. The opening clause should have a %s
  127. to represent the section title."
  128. :group 'org-export-latex
  129. :type '(repeat
  130. (list (string :tag "LaTeX class")
  131. (string :tag "LaTeX header")
  132. (repeat :tag "Levels" :inline t
  133. (choice
  134. (cons :tag "Heading"
  135. (string :tag "numbered")
  136. (string :tag "unnumbered)"))
  137. (list :tag "Environment"
  138. (string :tag "Opening (numbered) ")
  139. (string :tag "Closing (numbered) ")
  140. (string :tag "Opening (unnumbered)")
  141. (string :tag "Closing (unnumbered)")))))))
  142. (defcustom org-export-latex-emphasis-alist
  143. '(("*" "\\textbf{%s}" nil)
  144. ("/" "\\emph{%s}" nil)
  145. ("_" "\\underline{%s}" nil)
  146. ("+" "\\texttt{%s}" nil)
  147. ("=" "\\verb|%s|" nil)
  148. ("~" "\\verb|%s|" t))
  149. "Alist of LaTeX expressions to convert emphasis fontifiers.
  150. Each element of the list is a list of three elements.
  151. The first element is the character used as a marker for fontification.
  152. The second element is a formatting string to wrap fontified text with.
  153. The third element decides whether to protect converted text from other
  154. conversions."
  155. :group 'org-export-latex
  156. :type 'alist)
  157. (defcustom org-export-latex-title-command "\\maketitle"
  158. "The command used to insert the title just after \\begin{document}.
  159. If this string contains the formatting specification \"%s\" then
  160. it will be used as a formatting string, passing the title as an
  161. argument."
  162. :group 'org-export-latex
  163. :type 'string)
  164. (defcustom org-export-latex-date-format
  165. "%d %B %Y"
  166. "Format string for \\date{...}."
  167. :group 'org-export-latex
  168. :type 'string)
  169. (defcustom org-export-latex-tables-verbatim nil
  170. "When non-nil, tables are exported verbatim."
  171. :group 'org-export-latex
  172. :type 'boolean)
  173. (defcustom org-export-latex-tables-column-borders nil
  174. "When non-nil, group of columns are surrounded with borders."
  175. :group 'org-export-latex
  176. :type 'boolean)
  177. (defcustom org-export-latex-packages-alist nil
  178. "Alist of packages to be inserted in the header.
  179. Each cell is of the forma \( \"option\" . \"package\" \)."
  180. :group 'org-export-latex
  181. :type 'alist)
  182. (defcustom org-export-latex-low-levels 'description
  183. "How to convert sections below the current level of sectioning.
  184. This is specified by the `org-export-headline-levels' option or the
  185. value of \"H:\" in Org's #+OPTION line.
  186. This can be either nil (skip the sections), 'description (convert
  187. the sections as descriptive lists) or a string to be used instead
  188. of \\section{%s}. In this latter case, the %s stands here for the
  189. inserted headline and is mandatory."
  190. :group 'org-export-latex
  191. :type '(choice (const :tag "Ignore" nil)
  192. (symbol :tag "Convert as descriptive list" description)
  193. (string :tag "Use a section string" :value "\\subparagraph{%s}")))
  194. (defcustom org-export-latex-list-parameters
  195. '(:cbon "\\texttt{[ ]}" :cboff "\\texttt{[ ]}")
  196. "Parameters for the LaTeX list exporter.
  197. These parameters will be passed on to `org-list-to-latex', which in turn
  198. will pass them (combined with the LaTeX default list parameters) to
  199. `org-list-to-generic'."
  200. :group 'org-export-latex
  201. :type 'plist)
  202. (defcustom org-export-latex-remove-from-headlines
  203. '(:todo nil :priority nil :tags nil)
  204. "A plist of keywords to remove from headlines. OBSOLETE.
  205. Non-nil means remove this keyword type from the headline.
  206. Don't remove the keys, just change their values.
  207. Obsolete, this variable is no longer used. Use the separate
  208. variables `org-export-with-todo-keywords', `org-export-with-priority',
  209. and `org-export-with-tags' instead."
  210. :type 'plist
  211. :group 'org-export-latex)
  212. (defcustom org-export-latex-image-default-option "width=10em"
  213. "Default option for images."
  214. :group 'org-export-latex
  215. :type 'string)
  216. (defcustom org-export-latex-inline-image-extensions
  217. '("pdf" "jpeg" "jpg" "png")
  218. "Extensions of image files that can be inlined into LaTeX.
  219. Note that this depends on the way the LaTeX file is processed.
  220. The default setting (pdf and jpg) assumes that pdflatex is doing the
  221. processing. If you are using latex and dvips or something similar,
  222. only postscript files can be included."
  223. :group 'org-export-html
  224. :type '(repeat (string :tag "Extension")))
  225. (defcustom org-export-latex-coding-system nil
  226. "Coding system for the exported LaTex file."
  227. :group 'org-export-latex
  228. :type 'coding-system)
  229. (defgroup org-export-pdf nil
  230. "Options for exporting Org-mode files to PDF, via LaTeX."
  231. :tag "Org Export LaTeX"
  232. :group 'org-export-latex
  233. :group 'org-export)
  234. (defcustom org-export-pdf-remove-logfiles t
  235. "Non-nil means, remove the logfiles produced by PDF production.
  236. These are the .aux, .log, .out, and .toc files."
  237. :group 'org-export-latex
  238. :type 'boolean)
  239. ;;; Autoload functions:
  240. ;;;###autoload
  241. (defun org-export-as-latex-batch ()
  242. "Call `org-export-as-latex', may be used in batch processing.
  243. For example:
  244. emacs --batch
  245. --load=$HOME/lib/emacs/org.el
  246. --eval \"(setq org-export-headline-levels 2)\"
  247. --visit=MyFile --funcall org-export-as-latex-batch"
  248. (org-export-as-latex org-export-headline-levels 'hidden))
  249. ;;;###autoload
  250. (defun org-export-as-latex-to-buffer (arg)
  251. "Call `org-export-as-latex` with output to a temporary buffer.
  252. No file is created. The prefix ARG is passed through to `org-export-as-latex'."
  253. (interactive "P")
  254. (org-export-as-latex arg nil nil "*Org LaTeX Export*")
  255. (switch-to-buffer-other-window "*Org LaTeX Export*"))
  256. ;;;###autoload
  257. (defun org-replace-region-by-latex (beg end)
  258. "Replace the region from BEG to END with its LaTeX export.
  259. It assumes the region has `org-mode' syntax, and then convert it to
  260. LaTeX. This can be used in any buffer. For example, you could
  261. write an itemized list in `org-mode' syntax in an LaTeX buffer and
  262. then use this command to convert it."
  263. (interactive "r")
  264. (let (reg latex buf)
  265. (save-window-excursion
  266. (if (org-mode-p)
  267. (setq latex (org-export-region-as-latex
  268. beg end t 'string))
  269. (setq reg (buffer-substring beg end)
  270. buf (get-buffer-create "*Org tmp*"))
  271. (save-excursion
  272. (set-buffer buf)
  273. (erase-buffer)
  274. (insert reg)
  275. (org-mode)
  276. (setq latex (org-export-region-as-latex
  277. (point-min) (point-max) t 'string)))
  278. (kill-buffer buf)))
  279. (delete-region beg end)
  280. (insert latex)))
  281. ;;;###autoload
  282. (defun org-export-region-as-latex (beg end &optional body-only buffer)
  283. "Convert region from BEG to END in `org-mode' buffer to LaTeX.
  284. If prefix arg BODY-ONLY is set, omit file header, footer, and table of
  285. contents, and only produce the region of converted text, useful for
  286. cut-and-paste operations.
  287. If BUFFER is a buffer or a string, use/create that buffer as a target
  288. of the converted LaTeX. If BUFFER is the symbol `string', return the
  289. produced LaTeX as a string and leave not buffer behind. For example,
  290. a Lisp program could call this function in the following way:
  291. (setq latex (org-export-region-as-latex beg end t 'string))
  292. When called interactively, the output buffer is selected, and shown
  293. in a window. A non-interactive call will only retunr the buffer."
  294. (interactive "r\nP")
  295. (when (interactive-p)
  296. (setq buffer "*Org LaTeX Export*"))
  297. (let ((transient-mark-mode t) (zmacs-regions t)
  298. rtn)
  299. (goto-char end)
  300. (set-mark (point)) ;; to activate the region
  301. (goto-char beg)
  302. (setq rtn (org-export-as-latex
  303. nil nil nil
  304. buffer body-only))
  305. (if (fboundp 'deactivate-mark) (deactivate-mark))
  306. (if (and (interactive-p) (bufferp rtn))
  307. (switch-to-buffer-other-window rtn)
  308. rtn)))
  309. ;;;###autoload
  310. (defun org-export-as-latex (arg &optional hidden ext-plist
  311. to-buffer body-only pub-dir)
  312. "Export current buffer to a LaTeX file.
  313. If there is an active region, export only the region. The prefix
  314. ARG specifies how many levels of the outline should become
  315. headlines. The default is 3. Lower levels will be exported
  316. depending on `org-export-latex-low-levels'. The default is to
  317. convert them as description lists. When HIDDEN is non-nil, don't
  318. display the LaTeX buffer. EXT-PLIST is a property list with
  319. external parameters overriding org-mode's default settings, but
  320. still inferior to file-local settings. When TO-BUFFER is
  321. non-nil, create a buffer with that name and export to that
  322. buffer. If TO-BUFFER is the symbol `string', don't leave any
  323. buffer behind but just return the resulting LaTeX as a string.
  324. When BODY-ONLY is set, don't produce the file header and footer,
  325. simply return the content of \begin{document}...\end{document},
  326. without even the \begin{document} and \end{document} commands.
  327. when PUB-DIR is set, use this as the publishing directory."
  328. (interactive "P")
  329. ;; Make sure we have a file name when we need it.
  330. (when (and (not (or to-buffer body-only))
  331. (not buffer-file-name))
  332. (if (buffer-base-buffer)
  333. (org-set-local 'buffer-file-name
  334. (with-current-buffer (buffer-base-buffer)
  335. buffer-file-name))
  336. (error "Need a file name to be able to export")))
  337. (message "Exporting to LaTeX...")
  338. (remove-text-properties (point-min) (point-max)
  339. '(:org-license-to-kill nil))
  340. (org-update-radio-target-regexp)
  341. (org-export-latex-set-initial-vars ext-plist arg)
  342. (let* ((wcf (current-window-configuration))
  343. (opt-plist org-export-latex-options-plist)
  344. (region-p (org-region-active-p))
  345. (rbeg (and region-p (region-beginning)))
  346. (rend (and region-p (region-end)))
  347. (subtree-p
  348. (when region-p
  349. (save-excursion
  350. (goto-char rbeg)
  351. (and (org-at-heading-p)
  352. (>= (org-end-of-subtree t t) rend)))))
  353. (opt-plist (if subtree-p
  354. (org-export-add-subtree-options opt-plist rbeg)
  355. opt-plist))
  356. ;; Make sure the variable contains the updated values.
  357. (org-export-latex-options-plist opt-plist)
  358. (title (or (and subtree-p (org-export-get-title-from-subtree))
  359. (plist-get opt-plist :title)
  360. (and (not
  361. (plist-get opt-plist :skip-before-1st-heading))
  362. (org-export-grab-title-from-buffer))
  363. (file-name-sans-extension
  364. (file-name-nondirectory buffer-file-name))))
  365. (filename (concat (file-name-as-directory
  366. (or pub-dir
  367. (org-export-directory :LaTeX ext-plist)))
  368. (file-name-sans-extension
  369. (or (and subtree-p
  370. (org-entry-get rbeg "EXPORT_FILE_NAME" t))
  371. (file-name-nondirectory ;sans-extension
  372. buffer-file-name)))
  373. ".tex"))
  374. (filename (if (equal (file-truename filename)
  375. (file-truename buffer-file-name))
  376. (concat filename ".tex")
  377. filename))
  378. (buffer (if to-buffer
  379. (cond
  380. ((eq to-buffer 'string) (get-buffer-create
  381. "*Org LaTeX Export*"))
  382. (t (get-buffer-create to-buffer)))
  383. (find-file-noselect filename)))
  384. (odd org-odd-levels-only)
  385. (header (org-export-latex-make-header title opt-plist))
  386. (skip (cond (subtree-p nil)
  387. (region-p nil)
  388. (t (plist-get opt-plist :skip-before-1st-heading))))
  389. (text (plist-get opt-plist :text))
  390. (first-lines (if skip "" (org-export-latex-first-lines
  391. opt-plist rbeg)))
  392. (coding-system (and (boundp 'buffer-file-coding-system)
  393. buffer-file-coding-system))
  394. (coding-system-for-write (or org-export-latex-coding-system
  395. coding-system))
  396. (save-buffer-coding-system (or org-export-latex-coding-system
  397. coding-system))
  398. (region (buffer-substring
  399. (if region-p (region-beginning) (point-min))
  400. (if region-p (region-end) (point-max))))
  401. (string-for-export
  402. (org-export-preprocess-string
  403. region
  404. :emph-multiline t
  405. :for-LaTeX t
  406. :comments nil
  407. :tags (plist-get opt-plist :tags)
  408. :priority (plist-get opt-plist :priority)
  409. :footnotes (plist-get opt-plist :footnotes)
  410. :timestamps (plist-get opt-plist :timestamps)
  411. :todo-keywords (plist-get opt-plist :todo-keywords)
  412. :add-text (if (eq to-buffer 'string) nil text)
  413. :skip-before-1st-heading skip
  414. :select-tags (plist-get opt-plist :select-tags)
  415. :exclude-tags (plist-get opt-plist :exclude-tags)
  416. :LaTeX-fragments nil)))
  417. (set-buffer buffer)
  418. (erase-buffer)
  419. (and (fboundp 'set-buffer-file-coding-system)
  420. (set-buffer-file-coding-system coding-system-for-write))
  421. ;; insert the header and initial document commands
  422. (unless (or (eq to-buffer 'string) body-only)
  423. (insert header))
  424. ;; insert text found in #+TEXT
  425. (when (and text (not (eq to-buffer 'string)))
  426. (insert (org-export-latex-content
  427. text '(lists tables fixed-width keywords))
  428. "\n\n"))
  429. ;; insert lines before the first headline
  430. (unless (or skip (eq to-buffer 'string))
  431. (insert first-lines))
  432. ;; export the content of headlines
  433. (org-export-latex-global
  434. (with-temp-buffer
  435. (insert string-for-export)
  436. (goto-char (point-min))
  437. (when (re-search-forward "^\\(\\*+\\) " nil t)
  438. (let* ((asters (length (match-string 1)))
  439. (level (if odd (- asters 2) (- asters 1))))
  440. (setq org-export-latex-add-level
  441. (if odd (1- (/ (1+ asters) 2)) (1- asters)))
  442. (org-export-latex-parse-global level odd)))))
  443. ;; finalization
  444. (unless body-only (insert "\n\\end{document}"))
  445. (or to-buffer (save-buffer))
  446. (goto-char (point-min))
  447. (message "Exporting to LaTeX...done")
  448. (prog1
  449. (if (eq to-buffer 'string)
  450. (prog1 (buffer-substring (point-min) (point-max))
  451. (kill-buffer (current-buffer)))
  452. (current-buffer))
  453. (set-window-configuration wcf))))
  454. ;;;###autoload
  455. (defun org-export-as-pdf (arg &optional hidden ext-plist
  456. to-buffer body-only pub-dir)
  457. "Export as LaTeX, then process through to PDF."
  458. (interactive "P")
  459. (message "Exporting to PDF...")
  460. (let* ((wconfig (current-window-configuration))
  461. (lbuf (org-export-as-latex arg hidden ext-plist
  462. to-buffer body-only pub-dir))
  463. (file (buffer-file-name lbuf))
  464. (base (file-name-sans-extension (buffer-file-name lbuf)))
  465. (pdffile (concat base ".pdf")))
  466. (and (file-exists-p pdffile) (delete-file pdffile))
  467. (message "Processing LaTeX file...")
  468. (shell-command (format "pdflatex -interaction nonstopmode %s"
  469. (shell-quote-argument file)))
  470. (shell-command (format "pdflatex -interaction nonstopmode %s"
  471. (shell-quote-argument file)))
  472. (message "Processing LaTeX file...done")
  473. (if (not (file-exists-p pdffile))
  474. (error "PDF file was not produced")
  475. (set-window-configuration wconfig)
  476. (when org-export-pdf-remove-logfiles
  477. (dolist (ext '("aux" "log" "out" "toc"))
  478. (setq file (concat base "." ext))
  479. (and (file-exists-p file) (delete-file file))))
  480. (message "Exporting to PDF...done")
  481. pdffile)))
  482. ;;;###autoload
  483. (defun org-export-as-pdf-and-open (arg)
  484. "Export as LaTeX, then process through to PDF, and open."
  485. (interactive "P")
  486. (let ((pdffile (org-export-as-pdf arg)))
  487. (if pdffile
  488. (org-open-file pdffile)
  489. (error "PDF file was not produced"))))
  490. ;;; Parsing functions:
  491. (defun org-export-latex-parse-global (level odd)
  492. "Parse the current buffer recursively, starting at LEVEL.
  493. If ODD is non-nil, assume the buffer only contains odd sections.
  494. Return a list reflecting the document structure."
  495. (save-excursion
  496. (goto-char (point-min))
  497. (let* ((cnt 0) output
  498. (depth org-export-latex-sectioning-depth))
  499. (while (re-search-forward
  500. (concat "^\\(\\(?:\\*\\)\\{"
  501. (number-to-string (+ (if odd 2 1) level))
  502. "\\}\\) \\(.*\\)$")
  503. ;; make sure that there is no upper heading
  504. (when (> level 0)
  505. (save-excursion
  506. (save-match-data
  507. (re-search-forward
  508. (concat "^\\(\\(?:\\*\\)\\{"
  509. (number-to-string level)
  510. "\\}\\) \\(.*\\)$") nil t)))) t)
  511. (setq cnt (1+ cnt))
  512. (let* ((pos (match-beginning 0))
  513. (heading (match-string 2))
  514. (nlevel (if odd (/ (+ 3 level) 2) (1+ level))))
  515. (save-excursion
  516. (narrow-to-region
  517. (point)
  518. (save-match-data
  519. (if (re-search-forward
  520. (concat "^\\(\\(?:\\*\\)\\{"
  521. (number-to-string (+ (if odd 2 1) level))
  522. "\\}\\) \\(.*\\)$") nil t)
  523. (match-beginning 0)
  524. (point-max))))
  525. (goto-char (point-min))
  526. (setq output
  527. (append output
  528. (list
  529. (list
  530. `(pos . ,pos)
  531. `(level . ,nlevel)
  532. `(occur . ,cnt)
  533. `(heading . ,heading)
  534. `(content . ,(org-export-latex-parse-content))
  535. `(subcontent . ,(org-export-latex-parse-subcontent
  536. level odd)))))))
  537. (widen)))
  538. (list output))))
  539. (defun org-export-latex-parse-content ()
  540. "Extract the content of a section."
  541. (let ((beg (point))
  542. (end (if (re-search-forward "^\\(\\*\\)+ .*$" nil t)
  543. (progn (beginning-of-line) (point))
  544. (point-max))))
  545. (buffer-substring beg end)))
  546. (defun org-export-latex-parse-subcontent (level odd)
  547. "Extract the subcontent of a section at LEVEL.
  548. If ODD Is non-nil, assume subcontent only contains odd sections."
  549. (if (not (re-search-forward
  550. (concat "^\\(\\(?:\\*\\)\\{"
  551. (number-to-string (+ (if odd 4 2) level))
  552. "\\}\\) \\(.*\\)$")
  553. nil t))
  554. nil ; subcontent is nil
  555. (org-export-latex-parse-global (+ (if odd 2 1) level) odd)))
  556. ;;; Rendering functions:
  557. (defun org-export-latex-global (content)
  558. "Export CONTENT to LaTeX.
  559. CONTENT is an element of the list produced by
  560. `org-export-latex-parse-global'."
  561. (if (eq (car content) 'subcontent)
  562. (mapc 'org-export-latex-sub (cdr content))
  563. (org-export-latex-sub (car content))))
  564. (defun org-export-latex-sub (subcontent)
  565. "Export the list SUBCONTENT to LaTeX.
  566. SUBCONTENT is an alist containing information about the headline
  567. and its content."
  568. (let ((num (plist-get org-export-latex-options-plist :section-numbers)))
  569. (mapc (lambda(x) (org-export-latex-subcontent x num)) subcontent)))
  570. (defun org-export-latex-subcontent (subcontent num)
  571. "Export each cell of SUBCONTENT to LaTeX.
  572. If NUM, export sections as numerical sections."
  573. (let* ((heading (org-export-latex-fontify-headline
  574. (cdr (assoc 'heading subcontent))))
  575. (level (- (cdr (assoc 'level subcontent))
  576. org-export-latex-add-level))
  577. (occur (number-to-string (cdr (assoc 'occur subcontent))))
  578. (content (cdr (assoc 'content subcontent)))
  579. (subcontent (cadr (assoc 'subcontent subcontent)))
  580. (label (org-get-text-property-any 0 'target heading))
  581. (label-list (cons label (cdr (assoc label
  582. org-export-target-aliases)))))
  583. (cond
  584. ;; Normal conversion
  585. ((<= level org-export-latex-sectioning-depth)
  586. (let* ((sec (nth (1- level) org-export-latex-sectioning))
  587. start end)
  588. (if (consp (cdr sec))
  589. (setq start (nth (if num 0 2) sec)
  590. end (nth (if num 1 3) sec))
  591. (setq start (if num (car sec) (cdr sec))))
  592. (insert (format start heading) "\n")
  593. (when label
  594. (insert (mapconcat (lambda (l) (format "\\label{%s}" l))
  595. label-list "\n") "\n"))
  596. (insert (org-export-latex-content content))
  597. (cond ((stringp subcontent) (insert subcontent))
  598. ((listp subcontent) (org-export-latex-sub subcontent)))
  599. (if end (insert end "\n"))))
  600. ;; At a level under the hl option: we can drop this subsection
  601. ((> level org-export-latex-sectioning-depth)
  602. (cond ((eq org-export-latex-low-levels 'description)
  603. (insert (format "\\begin{description}\n\n\\item[%s]%s\n\n"
  604. heading
  605. (if label (format "\\label{%s}" label) "")))
  606. (insert (org-export-latex-content content))
  607. (cond ((stringp subcontent) (insert subcontent))
  608. ((listp subcontent) (org-export-latex-sub subcontent)))
  609. (insert "\\end{description}\n"))
  610. ((stringp org-export-latex-low-levels)
  611. (insert (format org-export-latex-low-levels heading) "\n")
  612. (when label (insert (format "\\label{%s}\n" label)))
  613. (insert (org-export-latex-content content))
  614. (cond ((stringp subcontent) (insert subcontent))
  615. ((listp subcontent) (org-export-latex-sub subcontent)))))))))
  616. ;;; Exporting internals:
  617. (defun org-export-latex-set-initial-vars (ext-plist level)
  618. "Store org local variables required for LaTeX export.
  619. EXT-PLIST is an optional additional plist.
  620. LEVEL indicates the default depth for export."
  621. (setq org-export-latex-todo-keywords-1 org-todo-keywords-1
  622. org-export-latex-all-targets-re
  623. (org-make-target-link-regexp (org-all-targets))
  624. org-export-latex-options-plist
  625. (org-combine-plists (org-default-export-plist) ext-plist
  626. (org-infile-export-plist))
  627. org-export-latex-class
  628. (or (and (org-region-active-p)
  629. (save-excursion
  630. (goto-char (region-beginning))
  631. (and (looking-at org-complex-heading-regexp)
  632. (org-entry-get nil "LaTeX_CLASS" 'selective))))
  633. (save-excursion
  634. (save-restriction
  635. (widen)
  636. (goto-char (point-min))
  637. (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([a-zA-Z]+\\)" nil t)
  638. (match-string 1))))
  639. org-export-latex-default-class)
  640. org-export-latex-class
  641. (or (car (assoc org-export-latex-class org-export-latex-classes))
  642. (error "No definition for class `%s' in `org-export-latex-classes'"
  643. org-export-latex-class))
  644. org-export-latex-header
  645. (cadr (assoc org-export-latex-class org-export-latex-classes))
  646. org-export-latex-sectioning
  647. (cddr (assoc org-export-latex-class org-export-latex-classes))
  648. org-export-latex-sectioning-depth
  649. (or level
  650. (let ((hl-levels
  651. (plist-get org-export-latex-options-plist :headline-levels))
  652. (sec-depth (length org-export-latex-sectioning)))
  653. (if (> hl-levels sec-depth) sec-depth hl-levels)))))
  654. (defun org-export-latex-make-header (title opt-plist)
  655. "Make the LaTeX header and return it as a string.
  656. TITLE is the current title from the buffer or region.
  657. OPT-PLIST is the options plist for current buffer."
  658. (let ((toc (plist-get opt-plist :table-of-contents))
  659. (author (plist-get opt-plist :author)))
  660. (concat
  661. (if (plist-get opt-plist :time-stamp-file)
  662. (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
  663. ;; insert LaTeX custom header
  664. org-export-latex-header
  665. "\n"
  666. ;; insert information on LaTeX packages
  667. (when org-export-latex-packages-alist
  668. (mapconcat (lambda(p)
  669. (if (equal "" (car p))
  670. (format "\\usepackage{%s}" (cadr p))
  671. (format "\\usepackage[%s]{%s}"
  672. (car p) (cadr p))))
  673. org-export-latex-packages-alist "\n"))
  674. ;; insert additional commands in the header
  675. (plist-get opt-plist :latex-header-extra)
  676. org-export-latex-append-header
  677. ;; insert the title
  678. (format
  679. "\n\n\\title{%s}\n"
  680. ;; convert the title
  681. (org-export-latex-content
  682. title '(lists tables fixed-width keywords)))
  683. ;; insert author info
  684. (if (plist-get opt-plist :author-info)
  685. (format "\\author{%s}\n"
  686. (or author user-full-name))
  687. (format "%%\\author{%s}\n"
  688. (or author user-full-name)))
  689. ;; insert the date
  690. (format "\\date{%s}\n"
  691. (format-time-string
  692. (or (plist-get opt-plist :date)
  693. org-export-latex-date-format)))
  694. ;; beginning of the document
  695. "\n\\begin{document}\n\n"
  696. ;; insert the title command
  697. (if (string-match "%s" org-export-latex-title-command)
  698. (format org-export-latex-title-command title)
  699. org-export-latex-title-command)
  700. "\n\n"
  701. ;; table of contents
  702. (when (and org-export-with-toc
  703. (plist-get opt-plist :section-numbers))
  704. (cond ((numberp toc)
  705. (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
  706. (min toc (plist-get opt-plist :headline-levels))))
  707. (toc (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
  708. (plist-get opt-plist :headline-levels))))))))
  709. (defun org-export-latex-first-lines (opt-plist &optional beg)
  710. "Export the first lines before first headline.
  711. If BEG is non-nil, the is the beginning of he region."
  712. (save-excursion
  713. (goto-char (or beg (point-min)))
  714. (if (org-at-heading-p) (beginning-of-line 2))
  715. (let* ((pt (point))
  716. (end (if (re-search-forward "^\\*+ " nil t)
  717. (goto-char (match-beginning 0))
  718. (goto-char (point-max)))))
  719. (prog1
  720. (org-export-latex-content
  721. (org-export-preprocess-string
  722. (buffer-substring pt end)
  723. :for-LaTeX t
  724. :emph-multiline t
  725. :add-text nil
  726. :comments nil
  727. :skip-before-1st-heading nil
  728. :LaTeX-fragments nil
  729. :timestamps (plist-get opt-plist :timestamps)
  730. :footnotes (plist-get opt-plist :footnotes)))
  731. (add-text-properties pt (max pt (1- end))
  732. '(:org-license-to-kill t))))))
  733. (defun org-export-latex-content (content &optional exclude-list)
  734. "Convert CONTENT string to LaTeX.
  735. Don't perform conversions that are in EXCLUDE-LIST. Recognized
  736. conversion types are: quotation-marks, emphasis, sub-superscript,
  737. links, keywords, lists, tables, fixed-width"
  738. (with-temp-buffer
  739. (insert content)
  740. (unless (memq 'quotation-marks exclude-list)
  741. (org-export-latex-quotation-marks))
  742. (unless (memq 'emphasis exclude-list)
  743. (when (plist-get org-export-latex-options-plist :emphasize)
  744. (org-export-latex-fontify)))
  745. (unless (memq 'sub-superscript exclude-list)
  746. (org-export-latex-special-chars
  747. (plist-get org-export-latex-options-plist :sub-superscript)))
  748. (unless (memq 'links exclude-list)
  749. (org-export-latex-links))
  750. (unless (memq 'keywords exclude-list)
  751. (org-export-latex-keywords))
  752. (unless (memq 'lists exclude-list)
  753. (org-export-latex-lists))
  754. (unless (memq 'tables exclude-list)
  755. (org-export-latex-tables
  756. (plist-get org-export-latex-options-plist :tables)))
  757. (unless (memq 'fixed-width exclude-list)
  758. (org-export-latex-fixed-width
  759. (plist-get org-export-latex-options-plist :fixed-width)))
  760. ;; return string
  761. (buffer-substring (point-min) (point-max))))
  762. (defun org-export-latex-protect-string (s)
  763. "Add the org-protected property to string S."
  764. (add-text-properties 0 (length s) '(org-protected t) s) s)
  765. (defun org-export-latex-protect-char-in-string (char-list string)
  766. "Add org-protected text-property to char from CHAR-LIST in STRING."
  767. (with-temp-buffer
  768. (save-match-data
  769. (insert string)
  770. (goto-char (point-min))
  771. (while (re-search-forward (regexp-opt char-list) nil t)
  772. (add-text-properties (match-beginning 0)
  773. (match-end 0) '(org-protected t)))
  774. (buffer-string))))
  775. (defun org-export-latex-keywords-maybe (&optional remove-list)
  776. "Maybe remove keywords depending on rules in REMOVE-LIST."
  777. (goto-char (point-min))
  778. (let ((re-todo (mapconcat 'identity org-export-latex-todo-keywords-1 "\\|"))
  779. (case-fold-search nil))
  780. ;; convert TODO keywords
  781. (when (re-search-forward (concat "^\\(" re-todo "\\)") nil t)
  782. (if (plist-get remove-list :todo)
  783. (replace-match "")
  784. (replace-match (format "\\textbf{%s}" (match-string 1)) t t)))
  785. ;; convert priority string
  786. (when (re-search-forward "\\[\\\\#.\\]" nil t)
  787. (if (plist-get remove-list :priority)
  788. (replace-match "")
  789. (replace-match (format "\\textbf{%s}" (match-string 0)) t t)))
  790. ;; convert tags
  791. (when (re-search-forward "\\(:[a-zA-Z0-9_@]+\\)+:" nil t)
  792. (if (or (not org-export-with-tags)
  793. (plist-get remove-list :tags))
  794. (replace-match "")
  795. (replace-match
  796. (org-export-latex-protect-string
  797. (format "\\textbf{%s}"
  798. (save-match-data
  799. (replace-regexp-in-string
  800. "_" "\\\\_" (match-string 0)))))
  801. t t)))))
  802. (defun org-export-latex-fontify-headline (string)
  803. "Fontify special words in STRING."
  804. (with-temp-buffer
  805. ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at
  806. ;; the beginning of the buffer - inserting "\n" is safe here though.
  807. (insert "\n" string)
  808. (goto-char (point-min))
  809. (when (plist-get org-export-latex-options-plist :emphasize)
  810. (org-export-latex-fontify))
  811. (org-export-latex-keywords-maybe)
  812. (org-export-latex-special-chars
  813. (plist-get org-export-latex-options-plist :sub-superscript))
  814. (org-export-latex-links)
  815. (org-trim (buffer-string))))
  816. (defun org-export-latex-quotation-marks ()
  817. "Export quotation marks depending on language conventions."
  818. (let* ((lang (plist-get org-export-latex-options-plist :language))
  819. (quote-rpl (if (equal lang "fr")
  820. '(("\\(\\s-\\)\"" "«~")
  821. ("\\(\\S-\\)\"" "~»")
  822. ("\\(\\s-\\)'" "`"))
  823. '(("\\(\\s-\\)\"" "``")
  824. ("\\(\\S-\\)\"" "''")
  825. ("\\(\\s-\\)'" "`")))))
  826. (mapc (lambda(l) (goto-char (point-min))
  827. (while (re-search-forward (car l) nil t)
  828. (let ((rpl (concat (match-string 1) (cadr l))))
  829. (org-export-latex-protect-string rpl)
  830. (org-if-unprotected-1
  831. (replace-match rpl t t))))) quote-rpl)))
  832. (defun org-export-latex-special-chars (sub-superscript)
  833. "Export special characters to LaTeX.
  834. If SUB-SUPERSCRIPT is non-nil, convert \\ and ^.
  835. See the `org-export-latex.el' code for a complete conversion table."
  836. (goto-char (point-min))
  837. (mapc (lambda(c)
  838. (goto-char (point-min))
  839. (while (re-search-forward c nil t)
  840. ;; Put the point where to check for org-protected
  841. (unless (get-text-property (match-beginning 2) 'org-protected)
  842. (cond ((member (match-string 2) '("\\$" "$"))
  843. (if (equal (match-string 2) "\\$")
  844. nil
  845. (replace-match "\\$" t t)))
  846. ((member (match-string 2) '("&" "%" "#"))
  847. (if (equal (match-string 1) "\\")
  848. (replace-match (match-string 2) t t)
  849. (replace-match (concat (match-string 1) "\\"
  850. (match-string 2)) t t)))
  851. ((equal (match-string 2) "...")
  852. (replace-match
  853. (concat (match-string 1)
  854. (org-export-latex-protect-string "\\ldots{}")) t t))
  855. ((equal (match-string 2) "~")
  856. (cond ((equal (match-string 1) "\\") nil)
  857. ((eq 'org-link (get-text-property 0 'face (match-string 2)))
  858. (replace-match (concat (match-string 1) "\\~") t t))
  859. (t (replace-match
  860. (org-export-latex-protect-string
  861. (concat (match-string 1) "\\~{}")) t t))))
  862. ((member (match-string 2) '("{" "}"))
  863. (unless (save-match-data (org-inside-latex-math-p))
  864. (if (equal (match-string 1) "\\")
  865. (replace-match (match-string 2) t t)
  866. (replace-match (concat (match-string 1) "\\"
  867. (match-string 2)) t t)))))
  868. (unless (save-match-data (org-inside-latex-math-p))
  869. (cond ((equal (match-string 2) "\\")
  870. (replace-match (or (save-match-data
  871. (org-export-latex-treat-backslash-char
  872. (match-string 1)
  873. (or (match-string 3) "")))
  874. "") t t))
  875. ((member (match-string 2) '("_" "^"))
  876. (replace-match (or (save-match-data
  877. (org-export-latex-treat-sub-super-char
  878. sub-superscript
  879. (match-string 2)
  880. (match-string 1)
  881. (match-string 3))) "") t t)))))))
  882. '(;"^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$"
  883. "\\(\\(\\\\?\\$\\)\\)"
  884. "\\([a-za-z0-9]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\([a-za-z0-9]+\\|[ \t\n]\\|[:punct:]\\|{[a-za-z0-9]+}\\|([a-za-z0-9]+)\\)"
  885. "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|[a-zA-Z&#%{}\"]+\\)"
  886. "\\(.\\|^\\)\\(&\\)"
  887. "\\(.\\|^\\)\\(#\\)"
  888. "\\(.\\|^\\)\\(%\\)"
  889. "\\(.\\|^\\)\\({\\)"
  890. "\\(.\\|^\\)\\(}\\)"
  891. "\\(.\\|^\\)\\(~\\)"
  892. "\\(.\\|^\\)\\(\\.\\.\\.\\)"
  893. ;; (?\< . "\\textless{}")
  894. ;; (?\> . "\\textgreater{}")
  895. )))
  896. (defun org-inside-latex-math-p ()
  897. (get-text-property (point) 'org-latex-math))
  898. (defun org-export-latex-treat-sub-super-char
  899. (subsup char string-before string-after)
  900. "Convert the \"_\" and \"^\" characters to LaTeX.
  901. SUBSUP corresponds to the ^: option in the #+OPTIONS line.
  902. Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
  903. (cond ((equal string-before "\\")
  904. (concat string-before char string-after))
  905. ;; this is part of a math formula
  906. ((and (string-match "\\S-+" string-before)
  907. (string-match "\\S-+" string-after))
  908. (cond ((eq 'org-link (get-text-property 0 'face char))
  909. (concat string-before "\\" char string-after))
  910. ((save-match-data (org-inside-latex-math-p))
  911. (if subsup
  912. (cond ((eq 1 (length string-after))
  913. (concat string-before char string-after))
  914. ((string-match "[({]?\\([^)}]+\\)[)}]?" string-after)
  915. (format "%s%s{%s}" string-before char
  916. (match-string 1 string-after))))))
  917. ((and (> (length string-after) 1)
  918. (or (eq subsup t)
  919. (and (equal subsup '{}) (eq (string-to-char string-after) ?\{)))
  920. (string-match "[({]?\\([^)}]+\\)[)}]?" string-after))
  921. (format "%s$%s{%s}$" string-before char
  922. (if (> (match-end 1) (1+ (match-beginning 1)))
  923. (concat "\\mathrm{" (match-string 1 string-after) "}")
  924. (match-string 1 string-after))))
  925. ((eq subsup t) (concat string-before "$" char string-after "$"))
  926. (t (org-export-latex-protect-string
  927. (concat string-before "\\" char "{}" string-after)))))
  928. (t (org-export-latex-protect-string
  929. (concat string-before "\\" char "{}" string-after)))))
  930. (defun org-export-latex-treat-backslash-char (string-before string-after)
  931. "Convert the \"$\" special character to LaTeX.
  932. The conversion is made depending of STRING-BEFORE and STRING-AFTER."
  933. (cond ((member (list string-after) org-html-entities)
  934. ;; backslash is part of a special entity (like "\alpha")
  935. (concat string-before "$\\"
  936. (or (cdar (member (list string-after) org-html-entities))
  937. string-after) "$"))
  938. ((and (not (string-match "^[ \n\t]" string-after))
  939. (not (string-match "[ \t]\\'\\|^" string-before)))
  940. ;; backslash is inside a word
  941. (org-export-latex-protect-string
  942. (concat string-before "\\textbackslash{}" string-after)))
  943. ((not (or (equal string-after "")
  944. (string-match "^[ \t\n]" string-after)))
  945. ;; backslash might escape a character (like \#) or a user TeX
  946. ;; macro (like \setcounter)
  947. (org-export-latex-protect-string
  948. (concat string-before "\\" string-after)))
  949. ((and (string-match "^[ \t\n]" string-after)
  950. (string-match "[ \t\n]\\'" string-before))
  951. ;; backslash is alone, convert it to $\backslash$
  952. (org-export-latex-protect-string
  953. (concat string-before "\\textbackslash{}" string-after)))
  954. (t (org-export-latex-protect-string
  955. (concat string-before "\\textbackslash{}" string-after)))))
  956. (defun org-export-latex-keywords ()
  957. "Convert special keywords to LaTeX."
  958. (goto-char (point-min))
  959. (let ((re (concat org-export-latex-special-keyword-regexp
  960. ".*" ; including the time stamp....
  961. )))
  962. (while (re-search-forward re nil t)
  963. (replace-match (format "\\\\texttt{%s}" (match-string 0)) t))))
  964. (defun org-export-latex-fixed-width (opt)
  965. "When OPT is non-nil convert fixed-width sections to LaTeX."
  966. (goto-char (point-min))
  967. (while (re-search-forward "^[ \t]*:\\([ \t]\\|$\\)" nil t)
  968. (if opt
  969. (progn (goto-char (match-beginning 0))
  970. (insert "\\begin{verbatim}\n")
  971. (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
  972. (replace-match (concat (match-string 1)
  973. (match-string 2)) t t)
  974. (forward-line))
  975. (insert "\\end{verbatim}\n\n"))
  976. (progn (goto-char (match-beginning 0))
  977. (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
  978. (replace-match (concat "%" (match-string 1)
  979. (match-string 2)) t t)
  980. (forward-line))))))
  981. (defvar org-table-last-alignment) ; defined in org-table.el
  982. (declare-function orgtbl-to-latex "org-table" (table params) t)
  983. (defun org-export-latex-tables (insert)
  984. "Convert tables to LaTeX and INSERT it."
  985. (goto-char (point-min))
  986. (while (re-search-forward "^\\([ \t]*\\)|" nil t)
  987. ;; FIXME really need to save-excursion?
  988. (save-excursion (org-table-align))
  989. (let* ((beg (org-table-begin))
  990. (end (org-table-end))
  991. (raw-table (buffer-substring beg end))
  992. fnum fields line lines olines gr colgropen line-fmt align
  993. caption label attr floatp longtblp)
  994. (if org-export-latex-tables-verbatim
  995. (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
  996. "\\end{verbatim}\n")))
  997. (apply 'delete-region (list beg end))
  998. (insert (org-export-latex-protect-string tbl)))
  999. (progn
  1000. (setq caption (org-find-text-property-in-string
  1001. 'org-caption raw-table)
  1002. attr (org-find-text-property-in-string
  1003. 'org-attributes raw-table)
  1004. label (org-find-text-property-in-string
  1005. 'org-label raw-table)
  1006. longtblp (and attr (stringp attr)
  1007. (string-match "\\<longtable\\>" attr))
  1008. align (and attr (stringp attr)
  1009. (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
  1010. (match-string 1 attr))
  1011. floatp (or caption label))
  1012. (setq lines (split-string raw-table "\n" t))
  1013. (apply 'delete-region (list beg end))
  1014. (when org-export-table-remove-special-lines
  1015. (setq lines (org-table-clean-before-export lines 'maybe-quoted)))
  1016. ;; make a formatting string to reflect aligment
  1017. (setq olines lines)
  1018. (while (and (not line-fmt) (setq line (pop olines)))
  1019. (unless (string-match "^[ \t]*|-" line)
  1020. (setq fields (org-split-string line "[ \t]*|[ \t]*"))
  1021. (setq fnum (make-vector (length fields) 0))
  1022. (setq line-fmt
  1023. (mapconcat
  1024. (lambda (x)
  1025. (setq gr (pop org-table-colgroup-info))
  1026. (format "%s%%s%s"
  1027. (cond ((eq gr ':start)
  1028. (prog1 (if colgropen "|" "")
  1029. (setq colgropen t)))
  1030. ((eq gr ':startend)
  1031. (prog1 (if colgropen "|" "|")
  1032. (setq colgropen nil)))
  1033. (t ""))
  1034. (if (memq gr '(:end :startend))
  1035. (progn (setq colgropen nil) "|")
  1036. "")))
  1037. fnum ""))))
  1038. ;; fix double || in line-fmt
  1039. (setq line-fmt (replace-regexp-in-string "||" "|" line-fmt))
  1040. ;; maybe remove the first and last "|"
  1041. (when (and (not org-export-latex-tables-column-borders)
  1042. (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt))
  1043. (setq line-fmt (match-string 2 line-fmt)))
  1044. ;; format alignment
  1045. (unless align
  1046. (setq align (apply 'format
  1047. (cons line-fmt
  1048. (mapcar (lambda (x) (if x "r" "l"))
  1049. org-table-last-alignment)))))
  1050. ;; prepare the table to send to orgtbl-to-latex
  1051. (setq lines
  1052. (mapcar
  1053. (lambda(elem)
  1054. (or (and (string-match "[ \t]*|-+" elem) 'hline)
  1055. (split-string (org-trim elem) "|" t)))
  1056. lines))
  1057. (when insert
  1058. (insert (org-export-latex-protect-string
  1059. (concat
  1060. (if longtblp
  1061. (concat "\\begin{longtable}{" align "}\n")
  1062. (if floatp "\\begin{table}[htb]\n"))
  1063. (if (or floatp longtblp)
  1064. (format
  1065. "\\caption{%s%s}"
  1066. (if label (concat "\\\label{" label "}") "")
  1067. (or caption "")))
  1068. (if longtblp "\\\\\n" "\n")
  1069. (if (not longtblp) "\\begin{center}\n")
  1070. (if (not longtblp) (concat "\\begin{tabular}{" align "}\n"))
  1071. (orgtbl-to-latex
  1072. lines
  1073. `(:tstart nil :tend nil
  1074. :hlend ,(if longtblp
  1075. (format "\\\\
  1076. \\hline
  1077. \\endhead
  1078. \\hline\\multicolumn{%d}{r}{Continued on next page}\\
  1079. \\endfoot
  1080. \\endlastfoot" (length org-table-last-alignment))
  1081. nil)))
  1082. (if (not longtblp) (concat "\n\\end{tabular}"))
  1083. (if longtblp "\n" "\n\\end{center}\n")
  1084. (if longtblp
  1085. "\\end{longtable}"
  1086. (if floatp "\\end{table}"))))
  1087. "\n\n")))))))
  1088. (defun org-export-latex-fontify ()
  1089. "Convert fontification to LaTeX."
  1090. (goto-char (point-min))
  1091. (while (re-search-forward org-emph-re nil t)
  1092. ;; The match goes one char after the *string*
  1093. (let ((emph (assoc (match-string 3)
  1094. org-export-latex-emphasis-alist))
  1095. (beg (match-beginning 0))
  1096. (end (match-end 0))
  1097. rpl)
  1098. (unless (or (get-text-property (1- (point)) 'org-protected)
  1099. (save-excursion
  1100. (goto-char (match-beginning 1))
  1101. (save-match-data
  1102. (and (org-at-table-p)
  1103. (string-match
  1104. "[|\n]" (buffer-substring beg end))))))
  1105. (setq rpl (concat (match-string 1)
  1106. (format (org-export-latex-protect-char-in-string
  1107. '("\\" "{" "}") (cadr emph))
  1108. (match-string 4))
  1109. (match-string 5)))
  1110. (if (caddr emph)
  1111. (setq rpl (org-export-latex-protect-string rpl)))
  1112. (replace-match rpl t t)))
  1113. (backward-char)))
  1114. (defun org-export-latex-links ()
  1115. ;; Make sure to use the LaTeX hyperref and graphicx package
  1116. ;; or send some warnings.
  1117. "Convert links to LaTeX."
  1118. (goto-char (point-min))
  1119. (while (re-search-forward org-bracket-link-analytic-regexp++ nil t)
  1120. (org-if-unprotected
  1121. (goto-char (match-beginning 0))
  1122. (let* ((re-radio org-export-latex-all-targets-re)
  1123. (remove (list (match-beginning 0) (match-end 0)))
  1124. (raw-path (org-extract-attributes (match-string 3)))
  1125. (full-raw-path (concat (match-string 1) raw-path))
  1126. (desc (match-string 5))
  1127. (type (or (match-string 2)
  1128. (if (or (file-name-absolute-p raw-path)
  1129. (string-match "^\\.\\.?/" raw-path))
  1130. "file")))
  1131. (coderefp (equal type "coderef"))
  1132. (caption (org-find-text-property-in-string 'org-caption raw-path))
  1133. (attr (org-find-text-property-in-string 'org-attributes raw-path))
  1134. (label (org-find-text-property-in-string 'org-label raw-path))
  1135. (floatp (or label caption))
  1136. imgp radiop
  1137. ;; define the path of the link
  1138. (path (cond
  1139. ((member type '("coderef"))
  1140. raw-path)
  1141. ((member type '("http" "https" "ftp"))
  1142. (concat type ":" raw-path))
  1143. ((and re-radio (string-match re-radio raw-path))
  1144. (setq radiop t))
  1145. ((equal type "mailto")
  1146. (concat type ":" raw-path))
  1147. ((equal type "file")
  1148. (if (and (org-file-image-p
  1149. (expand-file-name
  1150. raw-path)
  1151. org-export-latex-inline-image-extensions)
  1152. (equal desc full-raw-path))
  1153. (setq imgp t)
  1154. (progn (when (string-match "\\(.+\\)::.+" raw-path)
  1155. (setq raw-path (match-string 1 raw-path)))
  1156. (if (file-exists-p raw-path)
  1157. (concat type "://" (expand-file-name raw-path))
  1158. (concat type "://" (org-export-directory
  1159. :LaTeX org-export-latex-options-plist)
  1160. raw-path))))))))
  1161. ;; process with link inserting
  1162. (apply 'delete-region remove)
  1163. (cond ((and imgp (plist-get org-export-latex-options-plist :inline-images))
  1164. (insert
  1165. (concat
  1166. (if floatp "\\begin{figure}[htb]\n")
  1167. (format "\\centerline{\\includegraphics[%s]{%s}}\n"
  1168. (or attr org-export-latex-image-default-option)
  1169. (if (file-name-absolute-p raw-path)
  1170. (expand-file-name raw-path)
  1171. raw-path))
  1172. (if floatp
  1173. (format "\\caption{%s%s}\n"
  1174. (if label (concat "\\label{" label "}") "")
  1175. (or caption "")))
  1176. (if floatp "\\end{figure}\n"))))
  1177. (coderefp
  1178. (insert (format
  1179. (org-export-get-coderef-format path desc)
  1180. (cdr (assoc path org-export-code-refs)))))
  1181. (radiop (insert (format "\\hyperref[%s]{%s}"
  1182. (org-solidify-link-text raw-path) desc)))
  1183. ((not type)
  1184. (insert (format "\\hyperref[%s]{%s}"
  1185. (org-solidify-link-text raw-path) desc)))
  1186. (path (insert (format "\\href{%s}{%s}" path desc)))
  1187. (t (insert "\\texttt{" desc "}")))))))
  1188. (defvar org-latex-entities) ; defined below
  1189. (defvar org-latex-entities-regexp) ; defined below
  1190. (defun org-export-latex-preprocess ()
  1191. "Clean stuff in the LaTeX export."
  1192. ;; Preserve line breaks
  1193. (goto-char (point-min))
  1194. (while (re-search-forward "\\\\\\\\" nil t)
  1195. (add-text-properties (match-beginning 0) (match-end 0)
  1196. '(org-protected t)))
  1197. ;; Preserve latex environments
  1198. (goto-char (point-min))
  1199. (while (re-search-forward "^[ \t]*\\\\begin{\\([a-zA-Z]+\\)}" nil t)
  1200. (let* ((start (progn (beginning-of-line) (point)))
  1201. (end (or (and (re-search-forward
  1202. (concat "^[ \t]*\\\\end{" (match-string 1) "}") nil t)
  1203. (point-at-eol))
  1204. (point-max))))
  1205. (add-text-properties start end '(org-protected t))))
  1206. ;; Preserve math snippets
  1207. (let* ((matchers (plist-get org-format-latex-options :matchers))
  1208. (re-list org-latex-regexps)
  1209. beg end re e m n block off)
  1210. ;; Check the different regular expressions
  1211. (while (setq e (pop re-list))
  1212. (setq m (car e) re (nth 1 e) n (nth 2 e)
  1213. block (if (nth 3 e) "\n\n" ""))
  1214. (setq off (if (member m '("$" "$1")) 1 0))
  1215. (when (and (member m matchers) (not (equal m "begin")))
  1216. (goto-char (point-min))
  1217. (while (re-search-forward re nil t)
  1218. (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
  1219. (add-text-properties beg end '(org-protected t org-latex-math t))))))
  1220. ;; Convert LaTeX to \LaTeX{}
  1221. (goto-char (point-min))
  1222. (let ((case-fold-search nil))
  1223. (while (re-search-forward "\\([^+_]\\)LaTeX" nil t)
  1224. (org-if-unprotected
  1225. (replace-match (org-export-latex-protect-string
  1226. (concat (match-string 1) "\\LaTeX{}")) t t))))
  1227. ;; Convert blockquotes
  1228. (goto-char (point-min))
  1229. (while (search-forward "ORG-BLOCKQUOTE-START" nil t)
  1230. (replace-match "\\begin{quote}" t t))
  1231. (goto-char (point-min))
  1232. (while (search-forward "ORG-BLOCKQUOTE-END" nil t)
  1233. (replace-match "\\end{quote}" t t))
  1234. ;; Convert verse
  1235. (goto-char (point-min))
  1236. (while (search-forward "ORG-VERSE-START" nil t)
  1237. (replace-match "\\begin{verse}" t t))
  1238. (goto-char (point-min))
  1239. (while (search-forward "ORG-VERSE-END" nil t)
  1240. (replace-match "\\end{verse}" t t))
  1241. ;; Convert horizontal rules
  1242. (goto-char (point-min))
  1243. (while (re-search-forward "^----+.$" nil t)
  1244. (org-if-unprotected
  1245. (replace-match (org-export-latex-protect-string "\\hrule") t t)))
  1246. ;; Protect LaTeX commands like \command[...]{...} or \command{...}
  1247. (goto-char (point-min))
  1248. (while (re-search-forward "\\\\[a-zA-Z]+\\(?:\\[.*\\]\\)?{.*}" nil t)
  1249. (add-text-properties (match-beginning 0) (match-end 0)
  1250. '(org-protected t)))
  1251. ;; Protect LaTeX entities
  1252. (goto-char (point-min))
  1253. (while (re-search-forward org-latex-entities-regexp nil t)
  1254. (add-text-properties (match-beginning 0) (match-end 0)
  1255. '(org-protected t)))
  1256. ;; Replace radio links
  1257. (goto-char (point-min))
  1258. (while (re-search-forward
  1259. (concat "<<<?" org-export-latex-all-targets-re
  1260. ">>>?\\((INVISIBLE)\\)?") nil t)
  1261. (org-if-unprotected
  1262. (replace-match
  1263. (org-export-latex-protect-string
  1264. (format "\\label{%s}%s" (save-match-data (org-solidify-link-text
  1265. (match-string 1)))
  1266. (if (match-string 2) "" (match-string 1)))) t t)))
  1267. ;; Delete @<...> constructs
  1268. ;; Thanks to Daniel Clemente for this regexp
  1269. (goto-char (point-min))
  1270. (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t)
  1271. (org-if-unprotected
  1272. (replace-match "")))
  1273. ;; When converting to LaTeX, replace footnotes
  1274. ;; FIXME: don't protect footnotes from conversion
  1275. (when (plist-get org-export-latex-options-plist :footnotes)
  1276. (goto-char (point-min))
  1277. (while (re-search-forward "\\[\\([0-9]+\\)\\]" nil t)
  1278. (org-if-unprotected
  1279. (when (save-match-data
  1280. (save-excursion (beginning-of-line)
  1281. (looking-at "[^:|#]")))
  1282. (let ((foot-beg (match-beginning 0))
  1283. (foot-end (match-end 0))
  1284. (foot-prefix (match-string 0))
  1285. footnote footnote-rpl)
  1286. (save-excursion
  1287. (if (not (re-search-forward (concat "^" (regexp-quote foot-prefix))
  1288. nil t))
  1289. (replace-match "$^{\\1}$")
  1290. (replace-match "")
  1291. (let ((end (save-excursion
  1292. (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t)
  1293. (match-beginning 0) (point-max)))))
  1294. (setq footnote (concat (org-trim (buffer-substring (point) end))
  1295. " ")) ; prevent last } being part of a link
  1296. (delete-region (point) end))
  1297. (goto-char foot-beg)
  1298. (delete-region foot-beg foot-end)
  1299. (unless (null footnote)
  1300. (setq footnote-rpl (format "\\footnote{%s}" footnote))
  1301. (add-text-properties 0 10 '(org-protected t) footnote-rpl)
  1302. (add-text-properties (1- (length footnote-rpl))
  1303. (length footnote-rpl)
  1304. '(org-protected t) footnote-rpl)
  1305. (insert footnote-rpl)))
  1306. )))))
  1307. ;; Remove footnote section tag for LaTeX
  1308. (goto-char (point-min))
  1309. (while (re-search-forward
  1310. (concat "^" footnote-section-tag-regexp) nil t)
  1311. (org-if-unprotected
  1312. (replace-match "")))))
  1313. ;;; List handling:
  1314. (defun org-export-latex-lists ()
  1315. "Convert plain text lists in current buffer into LaTeX lists."
  1316. (goto-char (point-min))
  1317. (while (re-search-forward org-list-beginning-re nil t)
  1318. (org-if-unprotected
  1319. (beginning-of-line)
  1320. (insert (org-list-to-latex (org-list-parse-list t)
  1321. org-export-latex-list-parameters))
  1322. "\n")))
  1323. (defconst org-latex-entities
  1324. '("\\!"
  1325. "\\'"
  1326. "\\+"
  1327. "\\,"
  1328. "\\-"
  1329. "\\:"
  1330. "\\;"
  1331. "\\<"
  1332. "\\="
  1333. "\\>"
  1334. "\\Huge"
  1335. "\\LARGE"
  1336. "\\Large"
  1337. "\\Styles"
  1338. "\\\\"
  1339. "\\`"
  1340. "\\addcontentsline"
  1341. "\\address"
  1342. "\\addtocontents"
  1343. "\\addtocounter"
  1344. "\\addtolength"
  1345. "\\addvspace"
  1346. "\\alph"
  1347. "\\appendix"
  1348. "\\arabic"
  1349. "\\author"
  1350. "\\begin{array}"
  1351. "\\begin{center}"
  1352. "\\begin{description}"
  1353. "\\begin{enumerate}"
  1354. "\\begin{eqnarray}"
  1355. "\\begin{equation}"
  1356. "\\begin{figure}"
  1357. "\\begin{flushleft}"
  1358. "\\begin{flushright}"
  1359. "\\begin{itemize}"
  1360. "\\begin{list}"
  1361. "\\begin{minipage}"
  1362. "\\begin{picture}"
  1363. "\\begin{quotation}"
  1364. "\\begin{quote}"
  1365. "\\begin{tabbing}"
  1366. "\\begin{table}"
  1367. "\\begin{tabular}"
  1368. "\\begin{thebibliography}"
  1369. "\\begin{theorem}"
  1370. "\\begin{titlepage}"
  1371. "\\begin{verbatim}"
  1372. "\\begin{verse}"
  1373. "\\bf"
  1374. "\\bf"
  1375. "\\bibitem"
  1376. "\\bigskip"
  1377. "\\cdots"
  1378. "\\centering"
  1379. "\\circle"
  1380. "\\cite"
  1381. "\\cleardoublepage"
  1382. "\\clearpage"
  1383. "\\cline"
  1384. "\\closing"
  1385. "\\dashbox"
  1386. "\\date"
  1387. "\\ddots"
  1388. "\\dotfill"
  1389. "\\em"
  1390. "\\fbox"
  1391. "\\flushbottom"
  1392. "\\fnsymbol"
  1393. "\\footnote"
  1394. "\\footnotemark"
  1395. "\\footnotesize"
  1396. "\\footnotetext"
  1397. "\\frac"
  1398. "\\frame"
  1399. "\\framebox"
  1400. "\\hfill"
  1401. "\\hline"
  1402. "\\hrulespace"
  1403. "\\hspace"
  1404. "\\huge"
  1405. "\\hyphenation"
  1406. "\\include"
  1407. "\\includeonly"
  1408. "\\indent"
  1409. "\\input"
  1410. "\\it"
  1411. "\\kill"
  1412. "\\label"
  1413. "\\large"
  1414. "\\ldots"
  1415. "\\line"
  1416. "\\linebreak"
  1417. "\\linethickness"
  1418. "\\listoffigures"
  1419. "\\listoftables"
  1420. "\\location"
  1421. "\\makebox"
  1422. "\\maketitle"
  1423. "\\mark"
  1424. "\\mbox"
  1425. "\\medskip"
  1426. "\\multicolumn"
  1427. "\\multiput"
  1428. "\\newcommand"
  1429. "\\newcounter"
  1430. "\\newenvironment"
  1431. "\\newfont"
  1432. "\\newlength"
  1433. "\\newline"
  1434. "\\newpage"
  1435. "\\newsavebox"
  1436. "\\newtheorem"
  1437. "\\nocite"
  1438. "\\nofiles"
  1439. "\\noindent"
  1440. "\\nolinebreak"
  1441. "\\nopagebreak"
  1442. "\\normalsize"
  1443. "\\onecolumn"
  1444. "\\opening"
  1445. "\\oval"
  1446. "\\overbrace"
  1447. "\\overline"
  1448. "\\pagebreak"
  1449. "\\pagenumbering"
  1450. "\\pageref"
  1451. "\\pagestyle"
  1452. "\\par"
  1453. "\\parbox"
  1454. "\\put"
  1455. "\\raggedbottom"
  1456. "\\raggedleft"
  1457. "\\raggedright"
  1458. "\\raisebox"
  1459. "\\ref"
  1460. "\\rm"
  1461. "\\roman"
  1462. "\\rule"
  1463. "\\savebox"
  1464. "\\sc"
  1465. "\\scriptsize"
  1466. "\\setcounter"
  1467. "\\setlength"
  1468. "\\settowidth"
  1469. "\\sf"
  1470. "\\shortstack"
  1471. "\\signature"
  1472. "\\sl"
  1473. "\\small"
  1474. "\\smallskip"
  1475. "\\sqrt"
  1476. "\\tableofcontents"
  1477. "\\telephone"
  1478. "\\thanks"
  1479. "\\thispagestyle"
  1480. "\\tiny"
  1481. "\\title"
  1482. "\\tt"
  1483. "\\twocolumn"
  1484. "\\typein"
  1485. "\\typeout"
  1486. "\\underbrace"
  1487. "\\underline"
  1488. "\\usebox"
  1489. "\\usecounter"
  1490. "\\value"
  1491. "\\vdots"
  1492. "\\vector"
  1493. "\\verb"
  1494. "\\vfill"
  1495. "\\vline"
  1496. "\\vspace")
  1497. "A list of LaTeX commands to be protected when performing conversion.")
  1498. (defconst org-latex-entities-regexp
  1499. (let (names rest)
  1500. (dolist (x org-latex-entities)
  1501. (if (string-match "[a-z][A-Z]$" x)
  1502. (push x names)
  1503. (push x rest)))
  1504. (concat "\\(" (regexp-opt (nreverse names)) "\\>\\)"
  1505. "\\|\\(" (regexp-opt (nreverse rest)) "\\)")))
  1506. (provide 'org-export-latex)
  1507. ;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad
  1508. ;;; org-export-latex.el ends here