org-export-latex.el 56 KB

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