org-e-latex.el 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199
  1. ;;; org-e-latex.el --- LaTeX Back-End For Org Export Engine
  2. ;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
  3. ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
  4. ;; Keywords: outlines, hypermedia, calendar, wp
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;; This library implements a LaTeX back-end for Org generic exporter.
  17. ;; To test it, run
  18. ;;
  19. ;; M-: (org-export-to-buffer 'e-latex "*Test e-LaTeX*") RET
  20. ;;
  21. ;; in an org-mode buffer then switch to the buffer to see the LaTeX
  22. ;; export. See contrib/lisp/org-export.el for more details on how
  23. ;; this exporter works.
  24. ;; It introduces three new buffer keywords: "LATEX_CLASS",
  25. ;; "LATEX_CLASS_OPTIONS" and "LATEX_HEADER".
  26. ;;; Code:
  27. (eval-when-compile (require 'cl))
  28. (defvar org-export-latex-default-packages-alist)
  29. (defvar org-export-latex-packages-alist)
  30. (declare-function org-element-property "org-element" (property element))
  31. (declare-function org-element-normalize-string "org-element" (s))
  32. (declare-function org-element-parse-secondary-string
  33. "org-element" (string restriction &optional buffer))
  34. (defvar org-element-string-restrictions)
  35. (defvar org-element-object-restrictions)
  36. (declare-function org-export-clean-table "org-export" (table specialp))
  37. (declare-function org-export-data "org-export" (data backend info))
  38. (declare-function org-export-directory "org-export" (type plist))
  39. (declare-function org-export-expand-macro "org-export" (macro info))
  40. (declare-function org-export-first-sibling-p "org-export" (headline info))
  41. (declare-function org-export-footnote-first-reference-p "org-export"
  42. (footnote-reference info))
  43. (declare-function org-export-get-coderef-format "org-export" (path desc))
  44. (declare-function org-export-get-footnote-definition "org-export"
  45. (footnote-reference info))
  46. (declare-function org-export-get-footnote-number "org-export" (footnote info))
  47. (declare-function org-export-get-previous-element "org-export" (blob info))
  48. (declare-function org-export-get-relative-level "org-export" (headline info))
  49. (declare-function org-export-handle-code
  50. "org-export" (element info &optional num-fmt ref-fmt delayed))
  51. (declare-function org-export-included-file "org-export" (keyword backend info))
  52. (declare-function org-export-inline-image-p "org-export"
  53. (link &optional extensions))
  54. (declare-function org-export-last-sibling-p "org-export" (headline info))
  55. (declare-function org-export-low-level-p "org-export" (headline info))
  56. (declare-function org-export-output-file-name
  57. "org-export" (extension &optional subtreep pub-dir))
  58. (declare-function org-export-resolve-coderef "org-export" (ref info))
  59. (declare-function org-export-resolve-fuzzy-link "org-export" (link info))
  60. (declare-function org-export-secondary-string "org-export"
  61. (secondary backend info))
  62. (declare-function org-export-solidify-link-text "org-export" (s))
  63. (declare-function org-export-table-format-info "org-export" (table))
  64. (declare-function
  65. org-export-to-buffer "org-export"
  66. (backend buffer &optional subtreep visible-only body-only ext-plist))
  67. (declare-function
  68. org-export-to-file "org-export"
  69. (backend file &optional subtreep visible-only body-only ext-plist))
  70. ;;; Internal Variables
  71. (defconst org-e-latex-option-alist
  72. '((:date "DATE" nil org-e-latex-date-format t)
  73. (:latex-class "LATEX_CLASS" nil org-e-latex-default-class t)
  74. (:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t)
  75. (:latex-header-extra "LATEX_HEADER" nil nil newline))
  76. "Alist between LaTeX export properties and ways to set them.
  77. See `org-export-option-alist' for more information on the
  78. structure of the value.")
  79. ;;; User Configurable Variables
  80. (defgroup org-export-e-latex nil
  81. "Options for exporting Org mode files to LaTeX."
  82. :tag "Org Export LaTeX"
  83. :group 'org-export)
  84. ;;;; Preamble
  85. (defcustom org-e-latex-default-class "article"
  86. "The default LaTeX class."
  87. :group 'org-export-e-latex
  88. :type '(string :tag "LaTeX class"))
  89. (defcustom org-e-latex-classes
  90. '(("article"
  91. "\\documentclass[11pt]{article}"
  92. ("\\section{%s}" . "\\section*{%s}")
  93. ("\\subsection{%s}" . "\\subsection*{%s}")
  94. ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
  95. ("\\paragraph{%s}" . "\\paragraph*{%s}")
  96. ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
  97. ("report"
  98. "\\documentclass[11pt]{report}"
  99. ("\\part{%s}" . "\\part*{%s}")
  100. ("\\chapter{%s}" . "\\chapter*{%s}")
  101. ("\\section{%s}" . "\\section*{%s}")
  102. ("\\subsection{%s}" . "\\subsection*{%s}")
  103. ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
  104. ("book"
  105. "\\documentclass[11pt]{book}"
  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. The header string
  119. -----------------
  120. The HEADER-STRING is the header that will be inserted into the
  121. LaTeX file. It should contain the \\documentclass macro, and
  122. anything else that is needed for this setup. To this header, the
  123. following commands will be added:
  124. - Calls to \\usepackage for all packages mentioned in the
  125. variables `org-export-latex-default-packages-alist' and
  126. `org-export-latex-packages-alist'. Thus, your header
  127. definitions should avoid to also request these packages.
  128. - Lines specified via \"#+LaTeX_HEADER:\"
  129. If you need more control about the sequence in which the header
  130. is built up, or if you want to exclude one of these building
  131. blocks for a particular class, you can use the following
  132. macro-like placeholders.
  133. [DEFAULT-PACKAGES] \\usepackage statements for default packages
  134. [NO-DEFAULT-PACKAGES] do not include any of the default packages
  135. [PACKAGES] \\usepackage statements for packages
  136. [NO-PACKAGES] do not include the packages
  137. [EXTRA] the stuff from #+LaTeX_HEADER
  138. [NO-EXTRA] do not include #+LaTeX_HEADER stuff
  139. [BEAMER-HEADER-EXTRA] the beamer extra headers
  140. So a header like
  141. \\documentclass{article}
  142. [NO-DEFAULT-PACKAGES]
  143. [EXTRA]
  144. \\providecommand{\\alert}[1]{\\textbf{#1}}
  145. [PACKAGES]
  146. will omit the default packages, and will include the
  147. #+LaTeX_HEADER lines, then have a call to \\providecommand, and
  148. then place \\usepackage commands based on the content of
  149. `org-export-latex-packages-alist'.
  150. If your header, `org-export-latex-default-packages-alist' or
  151. `org-export-latex-packages-alist' inserts
  152. \"\\usepackage[AUTO]{inputenc}\", AUTO will automatically be
  153. replaced with a coding system derived from
  154. `buffer-file-coding-system'. See also the variable
  155. `org-e-latex-inputenc-alist' for a way to influence this
  156. mechanism.
  157. The sectioning structure
  158. ------------------------
  159. The sectioning structure of the class is given by the elements
  160. following the header string. For each sectioning level, a number
  161. of strings is specified. A %s formatter is mandatory in each
  162. section string and will be replaced by the title of the section.
  163. Instead of a cons cell \(numbered . unnumbered\), you can also
  164. provide a list of 2 or 4 elements,
  165. \(numbered-open numbered-close\)
  166. or
  167. \(numbered-open numbered-close unnumbered-open unnumbered-close\)
  168. providing opening and closing strings for a LaTeX environment
  169. that should represent the document section. The opening clause
  170. should have a %s to represent the section title.
  171. Instead of a list of sectioning commands, you can also specify
  172. a function name. That function will be called with two
  173. parameters, the \(reduced) level of the headline, and a predicate
  174. non-nil when the headline should be numbered. It must return
  175. a format string in which the section title will be added."
  176. :group 'org-export-e-latex
  177. :type '(repeat
  178. (list (string :tag "LaTeX class")
  179. (string :tag "LaTeX header")
  180. (repeat :tag "Levels" :inline t
  181. (choice
  182. (cons :tag "Heading"
  183. (string :tag " numbered")
  184. (string :tag "unnumbered"))
  185. (list :tag "Environment"
  186. (string :tag "Opening (numbered)")
  187. (string :tag "Closing (numbered)")
  188. (string :tag "Opening (unnumbered)")
  189. (string :tag "Closing (unnumbered)"))
  190. (function :tag "Hook computing sectioning"))))))
  191. (defcustom org-e-latex-inputenc-alist nil
  192. "Alist of inputenc coding system names, and what should really be used.
  193. For example, adding an entry
  194. (\"utf8\" . \"utf8x\")
  195. will cause \\usepackage[utf8x]{inputenc} to be used for buffers that
  196. are written as utf8 files."
  197. :group 'org-export-e-latex
  198. :type '(repeat
  199. (cons
  200. (string :tag "Derived from buffer")
  201. (string :tag "Use this instead"))))
  202. (defcustom org-e-latex-date-format
  203. "\\today"
  204. "Format string for \\date{...}."
  205. :group 'org-export-e-latex
  206. :type 'boolean)
  207. (defcustom org-e-latex-title-command "\\maketitle"
  208. "The command used to insert the title just after \\begin{document}.
  209. If this string contains the formatting specification \"%s\" then
  210. it will be used as a formatting string, passing the title as an
  211. argument."
  212. :group 'org-export-e-latex
  213. :type 'string)
  214. ;;;; Headline
  215. (defcustom org-e-latex-format-headline-function nil
  216. "Function to format headline text.
  217. This function will be called with 5 arguments:
  218. TODO the todo keyword \(string or nil\).
  219. TODO-TYPE the type of todo \(symbol: `todo', `done', nil\)
  220. PRIORITY the priority of the headline \(integer or nil\)
  221. TEXT the main headline text \(string\).
  222. TAGS the tags string, separated with colons \(string or nil\).
  223. The function result will be used in the section format string.
  224. As an example, one could set the variable to the following, in
  225. order to reproduce the default set-up:
  226. \(defun org-e-latex-format-headline \(todo todo-type priority text tags\)
  227. \"Default format function for an headline.\"
  228. \(concat \(when todo
  229. \(format \"\\\\textbf{\\\\textsc{\\\\textsf{%s}}} \" todo\)\)
  230. \(when priority
  231. \(format \"\\\\framebox{\\\\#%c} \" priority\)\)
  232. text
  233. \(when tags \(format \"\\\\hfill{}\\\\textsc{%s}\" tags\)\)\)\)"
  234. :group 'org-export-e-latex
  235. :type 'function)
  236. ;;;; Emphasis
  237. (defcustom org-e-latex-emphasis-alist
  238. '(("*" . "\\textbf{%s}")
  239. ("/" . "\\emph{%s}")
  240. ("_" . "\\underline{%s}")
  241. ("+" . "\\st{%s}")
  242. ("=" . protectedtexttt)
  243. ("~" . verb))
  244. "Alist of LaTeX expressions to convert emphasis fontifiers.
  245. The key is the character used as a marker for fontification. The
  246. value is a formatting string to wrap fontified text with.
  247. Value can also be set to the following symbols: `verb' and
  248. `protectedtexttt'. For the former, Org will use \"\\verb\" to
  249. create a format string and select a delimiter character that
  250. isn't in the string. For the latter, Org will use \"\\texttt\"
  251. to typeset and try to protect special characters."
  252. :group 'org-export-e-latex
  253. :type 'alist)
  254. ;;;; Footnotes
  255. (defcustom org-e-latex-footnote-separator "\\textsuperscript{,}\\,"
  256. "Text used to separate footnotes."
  257. :group 'org-export-e-latex
  258. :type 'string)
  259. ;;;; Time-stamps
  260. (defcustom org-e-latex-active-timestamp-format "\\textit{%s}"
  261. "A printf format string to be applied to active time-stamps."
  262. :group 'org-export-e-latex
  263. :type 'string)
  264. (defcustom org-e-latex-inactive-timestamp-format "\\textit{%s}"
  265. "A printf format string to be applied to inactive time-stamps."
  266. :group 'org-export-e-latex
  267. :type 'string)
  268. (defcustom org-e-latex-diary-timestamp-format "\\textit{%s}"
  269. "A printf format string to be applied to diary time-stamps."
  270. :group 'org-export-e-latex
  271. :type 'string)
  272. ;;;; Links
  273. (defcustom org-e-latex-image-default-option "width=.9\\linewidth"
  274. "Default option for images."
  275. :group 'org-export-e-latex
  276. :type 'string)
  277. (defcustom org-e-latex-default-figure-position "htb"
  278. "Default position for latex figures."
  279. :group 'org-export-e-latex
  280. :type 'string)
  281. (defcustom org-e-latex-inline-image-rules
  282. '(("file" . "\\.\\(pdf\\|jpeg\\|jpg\\|png\\|ps\\|eps\\)\\'"))
  283. "Rules characterizing image files that can be inlined into LaTeX.
  284. A rule consists in an association whose key is the type of link
  285. to consider, and value is a regexp that will be matched against
  286. link's path.
  287. Note that, by default, the image extension *actually* allowed
  288. depend on the way the LaTeX file is processed. When used with
  289. pdflatex, pdf, jpg and png images are OK. When processing
  290. through dvi to Postscript, only ps and eps are allowed. The
  291. default we use here encompasses both."
  292. :group 'org-export-e-latex
  293. :type '(alist :key-type (string :tag "Type")
  294. :value-type (regexp :tag "Path")))
  295. ;;;; Tables
  296. (defcustom org-e-latex-default-table-environment "tabular"
  297. "Default environment used to build tables."
  298. :group 'org-export-e-latex
  299. :type 'string)
  300. (defcustom org-e-latex-tables-centered t
  301. "When non-nil, tables are exported in a center environment."
  302. :group 'org-export-e-latex
  303. :type 'boolean)
  304. (defcustom org-e-latex-tables-verbatim nil
  305. "When non-nil, tables are exported verbatim."
  306. :group 'org-export-e-latex
  307. :type 'boolean)
  308. (defcustom org-e-latex-tables-booktabs nil
  309. "When non-nil, display tables in a formal \"booktabs\" style.
  310. This option assumes that the \"booktabs\" package is properly
  311. loaded in the header of the document. This value can be ignored
  312. locally with \"booktabs=yes\" and \"booktabs=no\" LaTeX
  313. attributes."
  314. :group 'org-export-e-latex
  315. :type 'boolean)
  316. (defcustom org-e-latex-table-caption-above t
  317. "When non-nil, place caption string at the beginning of the table.
  318. Otherwise, place it near the end."
  319. :group 'org-export-e-latex
  320. :type 'boolean)
  321. ;;;; Drawers
  322. (defcustom org-e-latex-format-drawer-function nil
  323. "Function called to format a drawer in LaTeX code.
  324. The function must accept two parameters:
  325. NAME the drawer name, like \"LOGBOOK\"
  326. CONTENTS the contents of the drawer.
  327. The function should return the string to be exported.
  328. For example, the variable could be set to the following function
  329. in order to mimic default behaviour:
  330. \(defun org-e-latex-format-drawer-default \(name contents\)
  331. \"Format a drawer element for LaTeX export.\"
  332. contents\)"
  333. :group 'org-export-e-latex
  334. :type 'function)
  335. ;;;; Inlinetasks
  336. (defcustom org-e-latex-format-inlinetask-function nil
  337. "Function called to format an inlinetask in LaTeX code.
  338. The function must accept six parameters:
  339. TODO the todo keyword, as a string
  340. TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
  341. PRIORITY the inlinetask priority, as a string
  342. NAME the inlinetask name, as a string.
  343. TAGS the inlinetask tags, as a string.
  344. CONTENTS the contents of the inlinetask, as a string.
  345. The function should return the string to be exported.
  346. For example, the variable could be set to the following function
  347. in order to mimic default behaviour:
  348. \(defun org-e-latex-format-inlinetask \(todo type priority name tags contents\)
  349. \"Format an inline task element for LaTeX export.\"
  350. \(let \(\(full-title
  351. \(concat
  352. \(when todo
  353. \(format \"\\\\textbf{\\\\textsf{\\\\textsc{%s}}} \" todo\)\)
  354. \(when priority \(format \"\\\\framebox{\\\\#%c} \" priority\)\)
  355. title
  356. \(when tags \(format \"\\\\hfill{}\\\\textsc{%s}\" tags\)\)\)\)\)
  357. \(format \(concat \"\\\\begin{center}\\n\"
  358. \"\\\\fbox{\\n\"
  359. \"\\\\begin{minipage}[c]{.6\\\\textwidth}\\n\"
  360. \"%s\\n\\n\"
  361. \"\\\\rule[.8em]{\\\\textwidth}{2pt}\\n\\n\"
  362. \"%s\"
  363. \"\\\\end{minipage}}\"
  364. \"\\\\end{center}\"\)
  365. full-title contents\)\)"
  366. :group 'org-export-e-latex
  367. :type 'function)
  368. ;; Src blocks
  369. (defcustom org-e-latex-listings nil
  370. "Non-nil means export source code using the listings package.
  371. This package will fontify source code, possibly even with color.
  372. If you want to use this, you also need to make LaTeX use the
  373. listings package, and if you want to have color, the color
  374. package. Just add these to `org-export-latex-packages-alist',
  375. for example using customize, or with something like:
  376. \(require 'org-e-latex)
  377. \(add-to-list 'org-export-latex-packages-alist '\(\"\" \"listings\"))
  378. \(add-to-list 'org-export-latex-packages-alist '\(\"\" \"color\"))
  379. Alternatively,
  380. \(setq org-e-latex-listings 'minted)
  381. causes source code to be exported using the minted package as
  382. opposed to listings. If you want to use minted, you need to add
  383. the minted package to `org-export-latex-packages-alist', for
  384. example using customize, or with
  385. \(require 'org-e-latex)
  386. \(add-to-list 'org-export-latex-packages-alist '\(\"\" \"minted\"))
  387. In addition, it is necessary to install pygments
  388. \(http://pygments.org), and to configure the variable
  389. `org-e-latex-pdf-process' so that the -shell-escape option is
  390. passed to pdflatex."
  391. :group 'org-export-e-latex
  392. :type '(choice
  393. (const :tag "Use listings" t)
  394. (const :tag "Use minted" 'minted)
  395. (const :tag "Export verbatim" nil)))
  396. (defcustom org-e-latex-listings-langs
  397. '((emacs-lisp "Lisp") (lisp "Lisp") (clojure "Lisp")
  398. (c "C") (cc "C++")
  399. (fortran "fortran")
  400. (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby")
  401. (html "HTML") (xml "XML")
  402. (tex "TeX") (latex "TeX")
  403. (shell-script "bash")
  404. (gnuplot "Gnuplot")
  405. (ocaml "Caml") (caml "Caml")
  406. (sql "SQL") (sqlite "sql"))
  407. "Alist mapping languages to their listing language counterpart.
  408. The key is a symbol, the major mode symbol without the \"-mode\".
  409. The value is the string that should be inserted as the language
  410. parameter for the listings package. If the mode name and the
  411. listings name are the same, the language does not need an entry
  412. in this list - but it does not hurt if it is present."
  413. :group 'org-export-e-latex
  414. :type '(repeat
  415. (list
  416. (symbol :tag "Major mode ")
  417. (string :tag "Listings language"))))
  418. (defcustom org-e-latex-listings-options nil
  419. "Association list of options for the latex listings package.
  420. These options are supplied as a comma-separated list to the
  421. \\lstset command. Each element of the association list should be
  422. a list containing two strings: the name of the option, and the
  423. value. For example,
  424. (setq org-e-latex-listings-options
  425. '((\"basicstyle\" \"\\small\")
  426. (\"keywordstyle\" \"\\color{black}\\bfseries\\underbar\")))
  427. will typeset the code in a small size font with underlined, bold
  428. black keywords.
  429. Note that the same options will be applied to blocks of all
  430. languages."
  431. :group 'org-export-e-latex
  432. :type '(repeat
  433. (list
  434. (string :tag "Listings option name ")
  435. (string :tag "Listings option value"))))
  436. (defcustom org-e-latex-minted-langs
  437. '((emacs-lisp "common-lisp")
  438. (cc "c++")
  439. (cperl "perl")
  440. (shell-script "bash")
  441. (caml "ocaml"))
  442. "Alist mapping languages to their minted language counterpart.
  443. The key is a symbol, the major mode symbol without the \"-mode\".
  444. The value is the string that should be inserted as the language
  445. parameter for the minted package. If the mode name and the
  446. listings name are the same, the language does not need an entry
  447. in this list - but it does not hurt if it is present.
  448. Note that minted uses all lower case for language identifiers,
  449. and that the full list of language identifiers can be obtained
  450. with:
  451. pygmentize -L lexers"
  452. :group 'org-export-e-latex
  453. :type '(repeat
  454. (list
  455. (symbol :tag "Major mode ")
  456. (string :tag "Minted language"))))
  457. (defcustom org-e-latex-minted-options nil
  458. "Association list of options for the latex minted package.
  459. These options are supplied within square brackets in
  460. \\begin{minted} environments. Each element of the alist should
  461. be a list containing two strings: the name of the option, and the
  462. value. For example,
  463. \(setq org-e-latex-minted-options
  464. '\((\"bgcolor\" \"bg\") \(\"frame\" \"lines\")))
  465. will result in src blocks being exported with
  466. \\begin{minted}[bgcolor=bg,frame=lines]{<LANG>}
  467. as the start of the minted environment. Note that the same
  468. options will be applied to blocks of all languages."
  469. :group 'org-export-e-latex
  470. :type '(repeat
  471. (list
  472. (string :tag "Minted option name ")
  473. (string :tag "Minted option value"))))
  474. (defvar org-e-latex-custom-lang-environments nil
  475. "Alist mapping languages to language-specific LaTeX environments.
  476. It is used during export of src blocks by the listings and minted
  477. latex packages. For example,
  478. \(setq org-e-latex-custom-lang-environments
  479. '\(\(python \"pythoncode\"\)\)\)
  480. would have the effect that if org encounters begin_src python
  481. during latex export it will output
  482. \\begin{pythoncode}
  483. <src block body>
  484. \\end{pythoncode}")
  485. ;;;; Plain text
  486. (defcustom org-e-latex-quotes
  487. '(("fr" ("\\(\\s-\\|[[(]\\)\"" . "«~") ("\\(\\S-\\)\"" . "~»") ("\\(\\s-\\|(\\)'" . "'"))
  488. ("en" ("\\(\\s-\\|[[(]\\)\"" . "``") ("\\(\\S-\\)\"" . "''") ("\\(\\s-\\|(\\)'" . "`")))
  489. "Alist for quotes to use when converting english double-quotes.
  490. The CAR of each item in this alist is the language code.
  491. The CDR of each item in this alist is a list of three CONS:
  492. - the first CONS defines the opening quote;
  493. - the second CONS defines the closing quote;
  494. - the last CONS defines single quotes.
  495. For each item in a CONS, the first string is a regexp
  496. for allowed characters before/after the quote, the second
  497. string defines the replacement string for this quote."
  498. :group 'org-export-e-latex
  499. :type '(list
  500. (cons :tag "Opening quote"
  501. (string :tag "Regexp for char before")
  502. (string :tag "Replacement quote "))
  503. (cons :tag "Closing quote"
  504. (string :tag "Regexp for char after ")
  505. (string :tag "Replacement quote "))
  506. (cons :tag "Single quote"
  507. (string :tag "Regexp for char before")
  508. (string :tag "Replacement quote "))))
  509. ;;;; Compilation
  510. (defcustom org-e-latex-pdf-process
  511. '("pdflatex -interaction nonstopmode -output-directory %o %f"
  512. "pdflatex -interaction nonstopmode -output-directory %o %f"
  513. "pdflatex -interaction nonstopmode -output-directory %o %f")
  514. "Commands to process a LaTeX file to a PDF file.
  515. This is a list of strings, each of them will be given to the
  516. shell as a command. %f in the command will be replaced by the
  517. full file name, %b by the file base name \(i.e. without
  518. extension) and %o by the base directory of the file.
  519. The reason why this is a list is that it usually takes several
  520. runs of `pdflatex', maybe mixed with a call to `bibtex'. Org
  521. does not have a clever mechanism to detect which of these
  522. commands have to be run to get to a stable result, and it also
  523. does not do any error checking.
  524. By default, Org uses 3 runs of `pdflatex' to do the processing.
  525. If you have texi2dvi on your system and if that does not cause
  526. the infamous egrep/locale bug:
  527. http://lists.gnu.org/archive/html/bug-texinfo/2010-03/msg00031.html
  528. then `texi2dvi' is the superior choice. Org does offer it as one
  529. of the customize options.
  530. Alternatively, this may be a Lisp function that does the
  531. processing, so you could use this to apply the machinery of
  532. AUCTeX or the Emacs LaTeX mode. This function should accept the
  533. file name as its single argument."
  534. :group 'org-export-pdf
  535. :type '(choice
  536. (repeat :tag "Shell command sequence"
  537. (string :tag "Shell command"))
  538. (const :tag "2 runs of pdflatex"
  539. ("pdflatex -interaction nonstopmode -output-directory %o %f"
  540. "pdflatex -interaction nonstopmode -output-directory %o %f"))
  541. (const :tag "3 runs of pdflatex"
  542. ("pdflatex -interaction nonstopmode -output-directory %o %f"
  543. "pdflatex -interaction nonstopmode -output-directory %o %f"
  544. "pdflatex -interaction nonstopmode -output-directory %o %f"))
  545. (const :tag "pdflatex,bibtex,pdflatex,pdflatex"
  546. ("pdflatex -interaction nonstopmode -output-directory %o %f"
  547. "bibtex %b"
  548. "pdflatex -interaction nonstopmode -output-directory %o %f"
  549. "pdflatex -interaction nonstopmode -output-directory %o %f"))
  550. (const :tag "texi2dvi"
  551. ("texi2dvi -p -b -c -V %f"))
  552. (const :tag "rubber"
  553. ("rubber -d --into %o %f"))
  554. (function)))
  555. (defcustom org-e-latex-logfiles-extensions
  556. '("aux" "idx" "log" "out" "toc" "nav" "snm" "vrb")
  557. "The list of file extensions to consider as LaTeX logfiles."
  558. :group 'org-export-e-latex
  559. :type '(repeat (string :tag "Extension")))
  560. (defcustom org-e-latex-remove-logfiles t
  561. "Non-nil means remove the logfiles produced by PDF production.
  562. These are the .aux, .log, .out, and .toc files."
  563. :group 'org-export-e-latex
  564. :type 'boolean)
  565. ;;; Internal Functions
  566. (defun org-e-latex--caption/label-string (caption label info)
  567. "Return caption and label LaTeX string for floats.
  568. CAPTION is a cons cell of secondary strings, the car being the
  569. standard caption and the cdr its short form. LABEL is a string
  570. representing the label. INFO is a plist holding contextual
  571. information.
  572. If there's no caption nor label, return the empty string.
  573. For non-floats, see `org-e-latex--wrap-label'."
  574. (let ((label-str (if label (format "\\label{%s}" label) "")))
  575. (cond
  576. ((and (not caption) (not label)) "")
  577. ((not caption) (format "\\label{%s}\n" label))
  578. ;; Option caption format with short name.
  579. ((cdr caption)
  580. (format "\\caption[%s]{%s%s}\n"
  581. (org-export-secondary-string (cdr caption) 'e-latex info)
  582. label-str
  583. (org-export-secondary-string (car caption) 'e-latex info)))
  584. ;; Standard caption format.
  585. (t (format "\\caption{%s%s}\n"
  586. label-str
  587. (org-export-secondary-string (car caption) 'e-latex info))))))
  588. (defun org-e-latex--guess-inputenc (header)
  589. "Set the coding system in inputenc to what the buffer is.
  590. HEADER is the LaTeX header string.
  591. Return the new header."
  592. (let* ((cs (or (ignore-errors
  593. (latexenc-coding-system-to-inputenc
  594. buffer-file-coding-system))
  595. "utf8")))
  596. (if (not cs) header
  597. ;; First translate if that is requested.
  598. (setq cs (or (cdr (assoc cs org-e-latex-inputenc-alist)) cs))
  599. ;; Then find the \usepackage statement and replace the option.
  600. (replace-regexp-in-string "\\\\usepackage\\[\\(AUTO\\)\\]{inputenc}"
  601. cs header t nil 1))))
  602. (defun org-e-latex--find-verb-separator (s)
  603. "Return a character not used in string S.
  604. This is used to choose a separator for constructs like \\verb."
  605. (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
  606. (loop for c across ll
  607. when (not (string-match (regexp-quote (char-to-string c)) s))
  608. return (char-to-string c))))
  609. (defun org-e-latex--make-option-string (options)
  610. "Return a comma separated string of keywords and values.
  611. OPTIONS is an alist where the key is the options keyword as
  612. a string, and the value a list containing the keyword value, or
  613. nil."
  614. (mapconcat (lambda (pair)
  615. (concat (first pair)
  616. (when (> (length (second pair)) 0)
  617. (concat "=" (second pair)))))
  618. options
  619. ","))
  620. (defun org-e-latex--quotation-marks (text info)
  621. "Export quotation marks depending on language conventions.
  622. TEXT is a string containing quotation marks to be replaced. INFO
  623. is a plist used as a communication channel."
  624. (mapc (lambda(l)
  625. (let ((start 0))
  626. (while (setq start (string-match (car l) text start))
  627. (let ((new-quote (concat (match-string 1 text) (cdr l))))
  628. (setq text (replace-match new-quote t t text))))))
  629. (cdr (or (assoc (plist-get info :language) org-e-latex-quotes)
  630. ;; Falls back on English.
  631. (assoc "en" org-e-latex-quotes))))
  632. text)
  633. (defun org-e-latex--wrap-label (element output)
  634. "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
  635. This function shouldn't be used for floats. See
  636. `org-e-latex--caption/label-string'."
  637. (let ((label (org-element-property :name element)))
  638. (if (or (not output) (not label) (string= output "") (string= label ""))
  639. output
  640. (concat (format "\\label{%s}\n" label) output))))
  641. ;;; Template
  642. (defun org-e-latex-template (contents info)
  643. "Return complete document string after LaTeX conversion.
  644. CONTENTS is the transcoded contents string. INFO is a plist
  645. holding export options."
  646. (let ((title (org-export-secondary-string
  647. (plist-get info :title) 'e-latex info)))
  648. (concat
  649. ;; 1. Time-stamp.
  650. (and (plist-get info :time-stamp-file)
  651. (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
  652. ;; 2. Document class and packages.
  653. (let ((class (plist-get info :latex-class))
  654. (class-options (plist-get info :latex-class-options)))
  655. (org-element-normalize-string
  656. (let* ((header (nth 1 (assoc class org-e-latex-classes)))
  657. (document-class-string
  658. (and (stringp header)
  659. (if class-options
  660. (replace-regexp-in-string
  661. "^[ \t]*\\\\documentclass\\(\\[.*?\\]\\)"
  662. class-options header t nil 1)
  663. header))))
  664. (org-e-latex--guess-inputenc
  665. (org-splice-latex-header
  666. document-class-string
  667. org-export-latex-default-packages-alist ; defined in org.el
  668. org-export-latex-packages-alist nil ; defined in org.el
  669. (plist-get info :latex-header-extra))))))
  670. ;; 3. Define alert if not yet defined.
  671. "\\providecommand{\\alert}[1]{\\textbf{#1}}\n"
  672. ;; 4. Possibly limit depth for headline numbering.
  673. (let ((sec-num (plist-get info :section-numbers)))
  674. (when (integerp sec-num)
  675. (format "\\setcounter{secnumdepth}{%d}\n" sec-num)))
  676. ;; 5. Author.
  677. (let ((author (and (plist-get info :with-author)
  678. (let ((auth (plist-get info :author)))
  679. (and auth (org-export-secondary-string
  680. auth 'e-latex info)))))
  681. (email (and (plist-get info :with-email)
  682. (org-export-secondary-string
  683. (plist-get info :email) 'e-latex info))))
  684. (cond ((and author email (not (string= "" email)))
  685. (format "\\author{%s\\thanks{%s}}\n" author email))
  686. (author (format "\\author{%s}\n" author))
  687. (t "\\author{}\n")))
  688. ;; 6. Date.
  689. (let ((date (plist-get info :date)))
  690. (and date (format "\\date{%s}\n" date)))
  691. ;; 7. Title
  692. (format "\\title{%s}\n" title)
  693. ;; 8. Hyperref options.
  694. (format "\\hypersetup{\n pdfkeywords={%s},\n pdfsubject={%s},\n pdfcreator={%s}}\n"
  695. (or (plist-get info :keywords) "")
  696. (or (plist-get info :description) "")
  697. (if (not (plist-get info :with-creator)) ""
  698. (plist-get info :creator)))
  699. ;; 9. Document start.
  700. "\\begin{document}\n\n"
  701. ;; 10. Title command.
  702. (org-element-normalize-string
  703. (cond ((string= "" title) nil)
  704. ((not (stringp org-e-latex-title-command)) nil)
  705. ((string-match "\\(?:[^%]\\|^\\)%s"
  706. org-e-latex-title-command)
  707. (format org-e-latex-title-command title))
  708. (t org-e-latex-title-command)))
  709. ;; 11. Table of contents.
  710. (let ((depth (plist-get info :with-toc)))
  711. (when depth
  712. (concat (when (wholenump depth)
  713. (format "\\setcounter{tocdepth}{%d}\n" depth))
  714. "\\tableofcontents\n\\vspace*{1cm}\n\n")))
  715. ;; 12. Document's body.
  716. contents
  717. ;; 13. Creator.
  718. (let ((creator-info (plist-get info :with-creator)))
  719. (cond
  720. ((not creator-info) "")
  721. ((eq creator-info 'comment)
  722. (format "%% %s\n" (plist-get info :creator)))
  723. (t (concat (plist-get info :creator) "\n"))))
  724. ;; 14. Document end.
  725. "\\end{document}")))
  726. ;;; Transcode Functions
  727. ;;;; Block
  728. (defun org-e-latex-center-block (center-block contents info)
  729. "Transcode a CENTER-BLOCK element from Org to LaTeX.
  730. CONTENTS holds the contents of the block. INFO is a plist
  731. holding contextual information."
  732. (org-e-latex--wrap-label
  733. center-block
  734. (format "\\begin{center}\n%s\\end{center}" contents)))
  735. ;;;; Comment
  736. ;; Comments are ignored.
  737. ;;;; Comment Block
  738. ;; Comment Blocks are ignored.
  739. ;;;; Drawer
  740. (defun org-e-latex-drawer (drawer contents info)
  741. "Transcode a DRAWER element from Org to LaTeX.
  742. CONTENTS holds the contents of the block. INFO is a plist
  743. holding contextual information."
  744. (let* ((name (org-element-property :drawer-name drawer))
  745. (output (if (functionp org-e-latex-format-drawer-function)
  746. (funcall org-e-latex-format-drawer-function
  747. name contents)
  748. ;; If there's no user defined function: simply
  749. ;; display contents of the drawer.
  750. contents)))
  751. (org-e-latex--wrap-label drawer output)))
  752. ;;;; Dynamic Block
  753. (defun org-e-latex-dynamic-block (dynamic-block contents info)
  754. "Transcode a DYNAMIC-BLOCK element from Org to LaTeX.
  755. CONTENTS holds the contents of the block. INFO is a plist
  756. holding contextual information. See
  757. `org-export-data'."
  758. (org-e-latex--wrap-label dynamic-block contents))
  759. ;;;; Emphasis
  760. (defun org-e-latex-emphasis (emphasis contents info)
  761. "Transcode EMPHASIS from Org to LaTeX.
  762. CONTENTS is the contents of the emphasized text. INFO is a plist
  763. holding contextual information.."
  764. (format (cdr (assoc (org-element-property :marker emphasis)
  765. org-e-latex-emphasis-alist))
  766. contents))
  767. ;;;; Entity
  768. (defun org-e-latex-entity (entity contents info)
  769. "Transcode an ENTITY object from Org to LaTeX.
  770. CONTENTS are the definition itself. INFO is a plist holding
  771. contextual information."
  772. (let ((ent (org-element-property :latex entity)))
  773. (if (org-element-property :latex-math-p entity) (format "$%s$" ent) ent)))
  774. ;;;; Example Block
  775. (defun org-e-latex-example-block (example-block contents info)
  776. "Transcode a EXAMPLE-BLOCK element from Org to LaTeX.
  777. CONTENTS is nil. INFO is a plist holding contextual information."
  778. (let* ((options (or (org-element-property :options example-block) ""))
  779. (value (org-export-handle-code example-block info)))
  780. (org-e-latex--wrap-label
  781. example-block (format "\\begin{verbatim}\n%s\\end{verbatim}" value))))
  782. ;;;; Export Snippet
  783. (defun org-e-latex-export-snippet (export-snippet contents info)
  784. "Transcode a EXPORT-SNIPPET object from Org to LaTeX.
  785. CONTENTS is nil. INFO is a plist holding contextual information."
  786. (when (eq (org-export-snippet-backend export-snippet) 'e-latex)
  787. (org-element-property :value export-snippet)))
  788. ;;;; Export Block
  789. (defun org-e-latex-export-block (export-block contents info)
  790. "Transcode a EXPORT-BLOCK element from Org to LaTeX.
  791. CONTENTS is nil. INFO is a plist holding contextual information."
  792. (when (string= (org-element-property :type export-block) "latex")
  793. (org-remove-indentation (org-element-property :value export-block))))
  794. ;;;; Fixed Width
  795. (defun org-e-latex-fixed-width (fixed-width contents info)
  796. "Transcode a FIXED-WIDTH element from Org to LaTeX.
  797. CONTENTS is nil. INFO is a plist holding contextual information."
  798. (let* ((value (org-element-normalize-string
  799. (replace-regexp-in-string
  800. "^[ \t]*: ?" ""
  801. (org-element-property :value fixed-width)))))
  802. (org-e-latex--wrap-label
  803. fixed-width (format "\\begin{verbatim}\n%s\\end{verbatim}" value))))
  804. ;;;; Footnote Definition
  805. ;; Footnote Definitions are ignored.
  806. ;;;; Footnote Reference
  807. (defun org-e-latex-footnote-reference (footnote-reference contents info)
  808. "Transcode a FOOTNOTE-REFERENCE element from Org to LaTeX.
  809. CONTENTS is nil. INFO is a plist holding contextual information."
  810. (concat
  811. ;; Insert separator between two footnotes in a row.
  812. (let ((prev (org-export-get-previous-element footnote-reference info)))
  813. (when (eq (org-element-type prev) 'footnote-reference)
  814. org-e-latex-footnote-separator))
  815. ;; Use \footnotemark if the footnote has already been defined.
  816. ;; Otherwise, define it with \footnote command.
  817. (cond
  818. ((not (org-export-footnote-first-reference-p footnote-reference info))
  819. (format "\\footnotemark[%s]"
  820. (org-export-get-footnote-number footnote-reference info)))
  821. ;; Inline definitions are secondary strings.
  822. ((eq (org-element-property :type footnote-reference) 'inline)
  823. (format "\\footnote{%s}"
  824. (org-trim
  825. (org-export-secondary-string
  826. (org-export-get-footnote-definition footnote-reference info)
  827. 'e-latex info))))
  828. ;; Non-inline footnotes definitions are full Org data.
  829. (t
  830. (format "\\footnote{%s}"
  831. (org-trim
  832. (org-export-data
  833. (org-export-get-footnote-definition footnote-reference info)
  834. 'e-latex info)))))))
  835. ;;;; Headline
  836. (defun org-e-latex-headline (headline contents info)
  837. "Transcode an HEADLINE element from Org to LaTeX.
  838. CONTENTS holds the contents of the headline. INFO is a plist
  839. holding contextual information."
  840. (let* ((class (plist-get info :latex-class))
  841. (numberedp (plist-get info :section-numbers))
  842. ;; Get level relative to current parsed data.
  843. (level (org-export-get-relative-level headline info))
  844. (class-sectionning (assoc class org-e-latex-classes))
  845. ;; Section formatting will set two placeholders: one for the
  846. ;; title and the other for the contents.
  847. (section-fmt
  848. (let ((sec (if (and (symbolp (nth 2 class-sectionning))
  849. (fboundp (nth 2 class-sectionning)))
  850. (funcall (nth 2 class-sectionning) level numberedp)
  851. (nth (1+ level) class-sectionning))))
  852. (cond
  853. ;; No section available for that LEVEL.
  854. ((not sec) nil)
  855. ;; Section format directly returned by a function.
  856. ((stringp sec) sec)
  857. ;; (numbered-section . unnumbered-section)
  858. ((not (consp (cdr sec)))
  859. (concat (funcall (if numberedp #'car #'cdr) sec) "\n%s"))
  860. ;; (numbered-open numbered-close)
  861. ((= (length sec) 2)
  862. (when numberedp (concat (car sec) "\n%s" (nth 1 sec))))
  863. ;; (num-in num-out no-num-in no-num-out)
  864. ((= (length sec) 4)
  865. (if numberedp
  866. (concat (car sec) "\n%s" (nth 1 sec))
  867. (concat (nth 2 sec) "\n%s" (nth 3 sec)))))))
  868. (text (org-export-secondary-string
  869. (org-element-property :title headline) 'e-latex info))
  870. (todo
  871. (and (plist-get info :with-todo-keywords)
  872. (let ((todo (org-element-property :todo-keyword headline)))
  873. (and todo (org-export-secondary-string todo 'e-latex info)))))
  874. (todo-type (and todo (org-element-property :todo-type headline)))
  875. (tags (and (plist-get info :with-tags)
  876. (org-element-property :tags headline)))
  877. (priority (and (plist-get info :with-priority)
  878. (org-element-property :priority headline)))
  879. ;; Create the headline text.
  880. (full-text (if (functionp org-e-latex-format-headline-function)
  881. ;; User-defined formatting function.
  882. (funcall org-e-latex-format-headline-function
  883. todo todo-type priority text tags)
  884. ;; Default formatting.
  885. (concat
  886. (when todo
  887. (format "\\textbf{\\textsf{\\textsc{%s}}} " todo))
  888. (when priority (format "\\framebox{\\#%c} " priority))
  889. text
  890. (when tags (format "\\hfill{}\\textsc{%s}" tags)))))
  891. ;; Associate some \label to the headline for internal links.
  892. (headline-label
  893. (format "\\label{sec-%s}\n"
  894. (mapconcat 'number-to-string
  895. (org-export-get-headline-number headline info)
  896. "-")))
  897. (pre-blanks
  898. (make-string (org-element-property :pre-blank headline) 10)))
  899. (cond
  900. ;; Case 1: This is a footnote section: ignore it.
  901. ((org-element-property :footnote-section-p headline) nil)
  902. ;; Case 2. This is a deep sub-tree: export it as a list item.
  903. ;; Also export as items headlines for which no section
  904. ;; format has been found.
  905. ((or (not section-fmt) (org-export-low-level-p headline info))
  906. ;; Build the real contents of the sub-tree.
  907. (let ((low-level-body
  908. (concat
  909. ;; If the headline is the first sibling, start a list.
  910. (when (org-export-first-sibling-p headline info)
  911. (format "\\begin{%s}\n" (if numberedp 'enumerate 'itemize)))
  912. ;; Itemize headline
  913. "\\item " full-text "\n" headline-label pre-blanks contents)))
  914. ;; If headline in the last sibling, close the list, before any
  915. ;; blank line. Otherwise, simply return LOW-LEVEL-BODY.
  916. (if (org-export-last-sibling-p headline info)
  917. (replace-regexp-in-string
  918. "[ \t\n]*\\'"
  919. (format "\n\\\\end{%s}" (if numberedp 'enumerate 'itemize))
  920. low-level-body)
  921. low-level-body)))
  922. ;; Case 3. Standard headline. Export it as a section.
  923. (t (format section-fmt full-text
  924. (concat headline-label pre-blanks contents))))))
  925. ;;;; Horizontal Rule
  926. (defun org-e-latex-horizontal-rule (horizontal-rule contents info)
  927. "Transcode an HORIZONTAL-RULE object from Org to LaTeX.
  928. CONTENTS is nil. INFO is a plist holding contextual information."
  929. (let ((attr (mapconcat #'identity
  930. (org-element-property :attr_latex horizontal-rule)
  931. " ")))
  932. (org-e-latex--wrap-label horizontal-rule (concat "\\hrule " attr))))
  933. ;;;; Inline Babel Call
  934. ;; Inline Babel Calls are ignored.
  935. ;;;; Inline Src Block
  936. (defun org-e-latex-inline-src-block (inline-src-block contents info)
  937. "Transcode an INLINE-SRC-BLOCK element from Org to LaTeX.
  938. CONTENTS holds the contents of the item. INFO is a plist holding
  939. contextual information."
  940. (let* ((code (org-element-property :value inline-src-block))
  941. (separator (org-e-latex--find-verb-separator code)))
  942. (cond
  943. ;; Do not use a special package: transcode it verbatim.
  944. ((not org-e-latex-listings)
  945. (concat "\\verb" separator code separator))
  946. ;; Use minted package.
  947. ((eq org-e-latex-listings 'minted)
  948. (let* ((org-lang (org-element-property :language inline-src-block))
  949. (mint-lang (or (cadr (assq (intern org-lang)
  950. org-e-latex-minted-langs))
  951. org-lang))
  952. (options (org-e-latex--make-option-string
  953. org-e-latex-minted-options)))
  954. (concat (format "\\mint%s{%s}"
  955. (if (string= options "") "" (format "[%s]" options))
  956. mint-lang)
  957. separator code separator)))
  958. ;; Use listings package.
  959. (t
  960. ;; Maybe translate language's name.
  961. (let* ((org-lang (org-element-property :language inline-src-block))
  962. (lst-lang (or (cadr (assq (intern org-lang)
  963. org-e-latex-listings-langs))
  964. org-lang))
  965. (options (org-e-latex--make-option-string
  966. (append org-e-latex-listings-options
  967. `(("language" ,lst-lang))))))
  968. (concat (format "\\lstinline[%s]" options)
  969. separator code separator))))))
  970. ;;;; Inlinetask
  971. (defun org-e-latex-inlinetask (inlinetask contents info)
  972. "Transcode an INLINETASK element from Org to LaTeX.
  973. CONTENTS holds the contents of the block. INFO is a plist
  974. holding contextual information."
  975. (let ((title (org-export-secondary-string
  976. (org-element-property :title inlinetask) 'e-latex info))
  977. (todo (and (plist-get info :with-todo-keywords)
  978. (let ((todo (org-element-property
  979. :todo-keyword inlinetask)))
  980. (and todo
  981. (org-export-secondary-string todo 'e-latex info)))))
  982. (todo-type (org-element-property :todo-type inlinetask))
  983. (tags (and (plist-get info :with-tags)
  984. (org-element-property :tags inlinetask)))
  985. (priority (and (plist-get info :with-priority)
  986. (org-element-property :priority inlinetask))))
  987. ;; If `org-e-latex-format-inlinetask-function' is provided, call it
  988. ;; with appropriate arguments.
  989. (if (functionp org-e-latex-format-inlinetask-function)
  990. (funcall org-e-latex-format-inlinetask-function
  991. todo todo-type priority title tags contents)
  992. ;; Otherwise, use a default template.
  993. (org-e-latex--wrap-label
  994. inlinetask
  995. (let ((full-title
  996. (concat
  997. (when todo (format "\\textbf{\\textsf{\\textsc{%s}}} " todo))
  998. (when priority (format "\\framebox{\\#%c} " priority))
  999. title
  1000. (when tags (format "\\hfill{}\\textsc{%s}" tags)))))
  1001. (format (concat "\\begin{center}\n"
  1002. "\\fbox{\n"
  1003. "\\begin{minipage}[c]{.6\\textwidth}\n"
  1004. "%s\n\n"
  1005. "\\rule[.8em]{\\textwidth}{2pt}\n\n"
  1006. "%s"
  1007. "\\end{minipage}\n"
  1008. "}\n"
  1009. "\\end{center}")
  1010. full-title contents))))))
  1011. ;;;; Item
  1012. (defun org-e-latex-item (item contents info)
  1013. "Transcode an ITEM element from Org to LaTeX.
  1014. CONTENTS holds the contents of the item. INFO is a plist holding
  1015. contextual information."
  1016. ;; Grab `:level' from plain-list properties, which is always the
  1017. ;; first element above current item.
  1018. (let* ((level (org-element-property :level (org-export-get-parent item info)))
  1019. (counter (let ((count (org-element-property :counter item)))
  1020. (and count
  1021. (< level 4)
  1022. (format "\\setcounter{enum%s}{%s}\n"
  1023. (nth level '("i" "ii" "iii" "iv"))
  1024. (1- count)))))
  1025. (checkbox (let ((checkbox (org-element-property :checkbox item)))
  1026. (cond ((eq checkbox 'on) "$\\boxtimes$ ")
  1027. ((eq checkbox 'off) "$\\Box$ ")
  1028. ((eq checkbox 'trans) "$\\boxminus$ "))))
  1029. (tag (let ((tag (org-element-property :tag item)))
  1030. (and tag
  1031. (format "[%s]" (org-export-secondary-string
  1032. tag 'e-latex info))))))
  1033. (concat counter "\\item" tag " " checkbox contents)))
  1034. ;;;; Keyword
  1035. (defun org-e-latex-keyword (keyword contents info)
  1036. "Transcode a KEYWORD element from Org to LaTeX.
  1037. CONTENTS is nil. INFO is a plist holding contextual information."
  1038. (let ((key (downcase (org-element-property :key keyword)))
  1039. (value (org-element-property :value keyword)))
  1040. (cond
  1041. ((string= key "latex") value)
  1042. ((string= key "index") (format "\\index{%s}" value))
  1043. ((string= key "target")
  1044. (format "\\label{%s}" (org-export-solidify-link-text value)))
  1045. ((string= key "toc")
  1046. (let ((value (downcase value)))
  1047. (cond
  1048. ((string-match "\\<headlines\\>" value)
  1049. (let ((depth (or (and (string-match "[0-9]+" value)
  1050. (string-to-number (match-string 0 value)))
  1051. (plist-get info :with-toc))))
  1052. (concat
  1053. (when (wholenump depth)
  1054. (format "\\setcounter{tocdepth}{%s}\n" depth))
  1055. "\\tableofcontents")))
  1056. ((string= "tables" value) "\\listoftables")
  1057. ((string= "figures" value) "\\listoffigures")
  1058. ((string= "listings" value)
  1059. (cond
  1060. ((eq org-e-latex-listings 'minted) "\\listoflistings")
  1061. (org-e-latex-listings "\\lstlistoflistings")
  1062. ;; At the moment, src blocks with a caption are wrapped
  1063. ;; into a figure environment.
  1064. (t "\\listoffigures")))))))))
  1065. ;;;; Latex Environment
  1066. (defun org-e-latex-latex-environment (latex-environment contents info)
  1067. "Transcode a LATEX-ENVIRONMENT element from Org to LaTeX.
  1068. CONTENTS is nil. INFO is a plist holding contextual information."
  1069. (let ((label (org-element-property :name latex-environment))
  1070. (value (org-remove-indentation
  1071. (org-element-property :value latex-environment))))
  1072. (if (not (org-string-nw-p label)) value
  1073. ;; Environment is labelled: label must be within the environment
  1074. ;; (otherwise, a reference pointing to that element will count
  1075. ;; the section instead).
  1076. (with-temp-buffer
  1077. (insert value)
  1078. (goto-char (point-min))
  1079. (forward-line)
  1080. (insert (format "\\label{%s}\n" label))
  1081. (buffer-string)))))
  1082. ;;;; Latex Fragment
  1083. (defun org-e-latex-latex-fragment (latex-fragment contents info)
  1084. "Transcode a LATEX-FRAGMENT object from Org to LaTeX.
  1085. CONTENTS is nil. INFO is a plist holding contextual information."
  1086. (org-element-property :value latex-fragment))
  1087. ;;;; Line Break
  1088. (defun org-e-latex-line-break (line-break contents info)
  1089. "Transcode a LINE-BREAK object from Org to LaTeX.
  1090. CONTENTS is nil. INFO is a plist holding contextual information."
  1091. "\\\\")
  1092. ;;;; Link
  1093. (defun org-e-latex-link--inline-image (link info)
  1094. "Return LaTeX code for an inline image.
  1095. LINK is the link pointing to the inline image. INFO is a plist
  1096. used as a communication channel."
  1097. (let* ((parent (org-export-get-parent-paragraph link info))
  1098. (path (let ((raw-path (org-element-property :path link)))
  1099. (if (not (file-name-absolute-p raw-path)) raw-path
  1100. (expand-file-name raw-path))))
  1101. (caption (org-e-latex--caption/label-string
  1102. (org-element-property :caption parent)
  1103. (org-element-property :name parent)
  1104. info))
  1105. ;; Retrieve latex attributes from the element around.
  1106. (attr (let ((raw-attr
  1107. (mapconcat #'identity
  1108. (org-element-property :attr_latex parent)
  1109. " ")))
  1110. (unless (string= raw-attr "") raw-attr)))
  1111. (disposition
  1112. (cond
  1113. ((and attr (string-match "\\<wrap\\>" attr)) 'wrap)
  1114. ((and attr (string-match "\\<multicolumn\\>" attr)) 'multicolumn)
  1115. ((or (and attr (string-match "\\<float\\>" attr))
  1116. (not (string= caption "")))
  1117. 'float)))
  1118. (placement
  1119. (cond
  1120. ((and attr (string-match "\\<placement=\\(\\S-+\\)" attr))
  1121. (org-match-string-no-properties 1 attr))
  1122. ((eq disposition 'wrap) "{l}{0.5\\textwidth}")
  1123. ((eq disposition 'float)
  1124. (concat "[" org-e-latex-default-figure-position "]"))
  1125. (t ""))))
  1126. ;; Now clear ATTR from any special keyword and set a default
  1127. ;; value if nothing is left.
  1128. (setq attr
  1129. (if (not attr) ""
  1130. (org-trim
  1131. (replace-regexp-in-string
  1132. "\\(wrap\\|multicolumn\\|float\\|placement=\\S-+\\)" "" attr))))
  1133. (setq attr (cond ((not (string= attr "")) attr)
  1134. ((eq disposition 'float) "width=0.7\\textwidth")
  1135. ((eq disposition 'wrap) "width=0.48\\textwidth")
  1136. (t (or org-e-latex-image-default-option ""))))
  1137. ;; Return proper string, depending on DISPOSITION.
  1138. (case disposition
  1139. (wrap (format "\\begin{wrapfigure}%s
  1140. \\centering
  1141. \\includegraphics[%s]{%s}
  1142. %s\\end{wrapfigure}" placement attr path caption))
  1143. (mulicolumn (format "\\begin{figure*}%s
  1144. \\centering
  1145. \\includegraphics[%s]{%s}
  1146. %s\\end{figure*}" placement attr path caption))
  1147. (float (format "\\begin{figure}%s
  1148. \\centering
  1149. \\includegraphics[%s]{%s}
  1150. %s\\end{figure}" placement attr path caption))
  1151. (t (format "\\includegraphics[%s]{%s}" attr path)))))
  1152. (defun org-e-latex-link (link desc info)
  1153. "Transcode a LINK object from Org to LaTeX.
  1154. DESC is the description part of the link, or the empty string.
  1155. INFO is a plist holding contextual information. See
  1156. `org-export-data'."
  1157. (let* ((type (org-element-property :type link))
  1158. (raw-path (org-element-property :path link))
  1159. ;; Ensure DESC really exists, or set it to nil.
  1160. (desc (and (not (string= desc "")) desc))
  1161. (imagep (org-export-inline-image-p
  1162. link org-e-latex-inline-image-rules))
  1163. (path (cond
  1164. ((member type '("http" "https" "ftp" "mailto"))
  1165. (concat type ":" raw-path))
  1166. ((string= type "file")
  1167. (when (string-match "\\(.+\\)::.+" raw-path)
  1168. (setq raw-path (match-string 1 raw-path)))
  1169. (if (file-name-absolute-p raw-path)
  1170. (concat "file://" (expand-file-name raw-path))
  1171. ;; TODO: Not implemented yet. Concat also:
  1172. ;; (org-export-directory :LaTeX info)
  1173. (concat "file://" raw-path)))
  1174. (t raw-path)))
  1175. protocol)
  1176. (cond
  1177. ;; Image file.
  1178. (imagep (org-e-latex-link--inline-image link info))
  1179. ;; Radioed target: Target's name is obtained from original raw
  1180. ;; link. Path is parsed and transcoded in order to have a proper
  1181. ;; display of the contents.
  1182. ((string= type "radio")
  1183. (format "\\hyperref[%s]{%s}"
  1184. (org-export-solidify-link-text path)
  1185. (org-export-secondary-string
  1186. (org-element-parse-secondary-string
  1187. path (cdr (assq 'radio-target org-element-object-restrictions)))
  1188. 'e-latex info)))
  1189. ;; Ref link: If no description is provided, reference label PATH
  1190. ;; and display table number. Otherwise move to label but display
  1191. ;; description instead.
  1192. ((string= type "ref")
  1193. (if (not desc) (format "\\ref{%s}" path)
  1194. (format "\\hyperref[%s]{%s}" path desc)))
  1195. ;; Links pointing to an headline: Find destination and build
  1196. ;; appropriate referencing command.
  1197. ((member type '("custom-id" "fuzzy" "id"))
  1198. (let ((destination (if (string= type "fuzzy")
  1199. (org-export-resolve-fuzzy-link link info)
  1200. (org-export-resolve-id-link link info))))
  1201. ;; Fuzzy link points to a target. Do as above.
  1202. (case (org-element-type destination)
  1203. (target
  1204. (format "\\hyperref[%s]{%s}"
  1205. (org-export-solidify-link-text
  1206. (org-element-property :raw-value destination))
  1207. (or desc
  1208. (org-export-secondary-string
  1209. (org-element-property :raw-link link)
  1210. 'e-latex info))))
  1211. ;; Fuzzy link points to an headline. If headlines are
  1212. ;; numbered and the link has no description, display
  1213. ;; headline's number. Otherwise, display description or
  1214. ;; headline's title.
  1215. (headline
  1216. (let ((label
  1217. (format "sec-%s"
  1218. (mapconcat
  1219. 'number-to-string
  1220. (org-export-get-headline-number destination info)
  1221. "-"))))
  1222. (if (and (plist-get info :section-numbers) (not desc))
  1223. (format "\\ref{%s}" label)
  1224. (format "\\hyperref[%s]{%s}" label
  1225. (or desc
  1226. (org-export-secondary-string
  1227. (org-element-property :title destination)
  1228. 'e-latex info))))))
  1229. ;; Fuzzy link points nowhere.
  1230. (otherwise
  1231. (format "\\texttt{%s}"
  1232. (or desc
  1233. (org-export-secondary-string
  1234. (org-element-property :raw-link link)
  1235. 'e-latex info)))))))
  1236. ;; Coderef: replace link with the reference name or the
  1237. ;; equivalent line number.
  1238. ((string= type "coderef")
  1239. (format (org-export-get-coderef-format path (or desc ""))
  1240. (org-export-resolve-coderef path info)))
  1241. ;; Link type is handled by a special function.
  1242. ((functionp (setq protocol (nth 2 (assoc type org-link-protocols))))
  1243. (funcall protocol (org-link-unescape path) desc 'latex))
  1244. ;; External link with a description part.
  1245. ((and path desc) (format "\\href{%s}{%s}" path desc))
  1246. ;; External link without a description part.
  1247. (path (format "\\url{%s}" path))
  1248. ;; No path, only description. Try to do something useful.
  1249. (t (format "\\texttt{%s}" desc)))))
  1250. ;;;; Babel Call
  1251. ;; Babel Calls are ignored.
  1252. ;;;; Macro
  1253. (defun org-e-latex-macro (macro contents info)
  1254. "Transcode a MACRO element from Org to LaTeX.
  1255. CONTENTS is nil. INFO is a plist holding contextual information."
  1256. ;; Use available tools.
  1257. (org-export-expand-macro macro info))
  1258. ;;;; Paragraph
  1259. (defun org-e-latex-paragraph (paragraph contents info)
  1260. "Transcode a PARAGRAPH element from Org to LaTeX.
  1261. CONTENTS is the contents of the paragraph, as a string. INFO is
  1262. the plist used as a communication channel."
  1263. contents)
  1264. ;;;; Plain List
  1265. (defun org-e-latex-plain-list (plain-list contents info)
  1266. "Transcode a PLAIN-LIST element from Org to LaTeX.
  1267. CONTENTS is the contents of the list. INFO is a plist holding
  1268. contextual information."
  1269. (let* ((type (org-element-property :type plain-list))
  1270. (paralist-types '("inparaenum" "asparaenum" "inparaitem" "asparaitem"
  1271. "inparadesc" "asparadesc"))
  1272. (paralist-regexp (concat
  1273. "\\("
  1274. (mapconcat 'identity paralist-types "\\|")
  1275. "\\)"))
  1276. (attr (mapconcat #'identity
  1277. (org-element-property :attr_latex plain-list)
  1278. " "))
  1279. (latex-type (cond
  1280. ((and attr
  1281. (string-match
  1282. (format "\\<%s\\>" paralist-regexp) attr))
  1283. (match-string 1 attr))
  1284. ((eq type 'ordered) "enumerate")
  1285. ((eq type 'unordered) "itemize")
  1286. ((eq type 'descriptive) "description"))))
  1287. (org-e-latex--wrap-label
  1288. plain-list
  1289. (format "\\begin{%s}%s\n%s\\end{%s}"
  1290. latex-type
  1291. ;; Once special environment, if any, has been removed, the
  1292. ;; rest of the attributes will be optional arguments.
  1293. ;; They will be put inside square brackets if necessary.
  1294. (let ((opt (replace-regexp-in-string
  1295. (format " *%s *" paralist-regexp) "" attr)))
  1296. (cond ((string= opt "") "")
  1297. ((string-match "\\`\\[[^][]+\\]\\'" opt) opt)
  1298. (t (format "[%s]" opt))))
  1299. contents
  1300. latex-type))))
  1301. ;;;; Plain Text
  1302. (defun org-e-latex-plain-text (text info)
  1303. "Transcode a TEXT string from Org to LaTeX.
  1304. TEXT is the string to transcode. INFO is a plist holding
  1305. contextual information."
  1306. ;; Protect %, #, &, $, ~, ^, _, { and }.
  1307. (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" text)
  1308. (setq text
  1309. (replace-match (format "\\%s" (match-string 2 text)) nil t text 2)))
  1310. ;; Protect \
  1311. (setq text (replace-regexp-in-string
  1312. "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
  1313. "$\\backslash$" text nil t 1))
  1314. ;; LaTeX into \LaTeX{} and TeX into \TeX{}.
  1315. (let ((case-fold-search nil)
  1316. (start 0))
  1317. (while (string-match "\\<\\(\\(?:La\\)?TeX\\)\\>" text start)
  1318. (setq text (replace-match
  1319. (format "\\%s{}" (match-string 1 text)) nil t text)
  1320. start (match-end 0))))
  1321. ;; Handle quotation marks
  1322. (setq text (org-e-latex--quotation-marks text info))
  1323. ;; Convert special strings.
  1324. (when (plist-get info :with-special-strings)
  1325. (while (string-match (regexp-quote "...") text)
  1326. (setq text (replace-match "\\ldots{}" nil t text))))
  1327. ;; Handle break preservation if required.
  1328. (when (plist-get info :preserve-breaks)
  1329. (setq text (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n"
  1330. text)))
  1331. ;; Return value.
  1332. text)
  1333. ;;;; Property Drawer
  1334. (defun org-e-latex-property-drawer (property-drawer contents info)
  1335. "Transcode a PROPERTY-DRAWER element from Org to LaTeX.
  1336. CONTENTS is nil. INFO is a plist holding contextual
  1337. information."
  1338. ;; The property drawer isn't exported but we want separating blank
  1339. ;; lines nonetheless.
  1340. "")
  1341. ;;;; Quote Block
  1342. (defun org-e-latex-quote-block (quote-block contents info)
  1343. "Transcode a QUOTE-BLOCK element from Org to LaTeX.
  1344. CONTENTS holds the contents of the block. INFO is a plist
  1345. holding contextual information."
  1346. (org-e-latex--wrap-label
  1347. quote-block
  1348. (format "\\begin{quote}\n%s\\end{quote}" contents)))
  1349. ;;;; Quote Section
  1350. (defun org-e-latex-quote-section (quote-section contents info)
  1351. "Transcode a QUOTE-SECTION element from Org to LaTeX.
  1352. CONTENTS is nil. INFO is a plist holding contextual information."
  1353. (let ((value (org-remove-indentation
  1354. (org-element-property :value quote-section))))
  1355. (when value (format "\\begin{verbatim}\n%s\\end{verbatim}" value))))
  1356. ;;;; Section
  1357. (defun org-e-latex-section (section contents info)
  1358. "Transcode a SECTION element from Org to LaTeX.
  1359. CONTENTS holds the contents of the section. INFO is a plist
  1360. holding contextual information."
  1361. contents)
  1362. ;;;; Radio Target
  1363. (defun org-e-latex-radio-target (radio-target text info)
  1364. "Transcode a RADIO-TARGET object from Org to LaTeX.
  1365. TEXT is the text of the target. INFO is a plist holding
  1366. contextual information."
  1367. (format "\\label{%s}%s"
  1368. (org-export-solidify-link-text
  1369. (org-element-property :raw-value radio-target))
  1370. text))
  1371. ;;;; Special Block
  1372. (defun org-e-latex-special-block (special-block contents info)
  1373. "Transcode a SPECIAL-BLOCK element from Org to LaTeX.
  1374. CONTENTS holds the contents of the block. INFO is a plist
  1375. holding contextual information."
  1376. (let ((type (downcase (org-element-property :type special-block))))
  1377. (org-e-latex--wrap-label
  1378. special-block
  1379. (format "\\begin{%s}\n%s\\end{%s}" type contents type))))
  1380. ;;;; Src Block
  1381. (defun org-e-latex-src-block (src-block contents info)
  1382. "Transcode a SRC-BLOCK element from Org to LaTeX.
  1383. CONTENTS holds the contents of the item. INFO is a plist holding
  1384. contextual information."
  1385. (let* ((lang (org-element-property :language src-block))
  1386. (code (org-export-handle-code src-block info))
  1387. (caption (org-element-property :caption src-block))
  1388. (label (org-element-property :name src-block))
  1389. (custom-env (and lang
  1390. (cadr (assq (intern lang)
  1391. org-e-latex-custom-lang-environments)))))
  1392. (cond
  1393. ;; No source fontification.
  1394. ((not org-e-latex-listings)
  1395. (let ((caption-str (org-e-latex--caption/label-string
  1396. caption label info))
  1397. (float-env (when caption "\\begin{figure}[H]\n%s\n\\end{figure}")))
  1398. (format (or float-env "%s")
  1399. (concat
  1400. caption-str
  1401. (format "\\begin{verbatim}\n%s\\end{verbatim}" code)))))
  1402. ;; Custom environment.
  1403. (custom-env
  1404. (format "\\begin{%s}\n%s\\end{%s}\n" custom-env code custom-env))
  1405. ;; Use minted package.
  1406. ((eq org-e-latex-listings 'minted)
  1407. (let* ((mint-lang (or (cadr (assq (intern lang) org-e-latex-minted-langs))
  1408. lang))
  1409. (float-env (when (or label caption)
  1410. (format "\\begin{listing}[H]\n%%s\n%s\\end{listing}"
  1411. (org-e-latex--caption/label-string
  1412. caption label info))))
  1413. (body (format "\\begin{minted}[%s]{%s}\n%s\\end{minted}"
  1414. (org-e-latex--make-option-string
  1415. org-e-latex-minted-options)
  1416. mint-lang code)))
  1417. (if float-env (format float-env body) body)))
  1418. ;; Use listings package.
  1419. (t
  1420. (let ((lst-lang
  1421. (or (cadr (assq (intern lang) org-e-latex-listings-langs)) lang))
  1422. (caption-str
  1423. (when caption
  1424. (let ((main (org-export-secondary-string
  1425. (car caption) 'e-latex info)))
  1426. (if (not (cdr caption)) (format "{%s}" main)
  1427. (format
  1428. "{[%s]%s}"
  1429. (org-export-secondary-string (cdr caption) 'e-latex info)
  1430. main))))))
  1431. (concat (format "\\lstset{%s}\n"
  1432. (org-e-latex--make-option-string
  1433. (append org-e-latex-listings-options
  1434. `(("language" ,lst-lang))
  1435. (when label `(("label" ,label)))
  1436. (when caption-str
  1437. `(("caption" ,caption-str))))))
  1438. (format "\\begin{lstlisting}\n%s\\end{lstlisting}" code)))))))
  1439. ;;;; Statistics Cookie
  1440. (defun org-e-latex-statistics-cookie (statistics-cookie contents info)
  1441. "Transcode a STATISTICS-COOKIE object from Org to LaTeX.
  1442. CONTENTS is nil. INFO is a plist holding contextual information."
  1443. (org-element-property :value statistics-cookie))
  1444. ;;;; Subscript
  1445. (defun org-e-latex-subscript (subscript contents info)
  1446. "Transcode a SUBSCRIPT object from Org to LaTeX.
  1447. CONTENTS is the contents of the object. INFO is a plist holding
  1448. contextual information."
  1449. (format (if (= (length contents) 1) "$_%s$" "$_{\\mathrm{%s}}$") contents))
  1450. ;;;; Superscript
  1451. (defun org-e-latex-superscript (superscript contents info)
  1452. "Transcode a SUPERSCRIPT object from Org to LaTeX.
  1453. CONTENTS is the contents of the object. INFO is a plist holding
  1454. contextual information."
  1455. (format (if (= (length contents) 1) "$^%s$" "$^{\\mathrm{%s}}$") contents))
  1456. ;;;; Table
  1457. (defun org-e-latex-table--format-string (table table-info info)
  1458. "Return an appropriate format string for TABLE.
  1459. TABLE-INFO is the plist containing format info about the table,
  1460. as returned by `org-export-table-format-info'. INFO is a plist
  1461. used as a communication channel.
  1462. The format string leaves one placeholder for the body of the
  1463. table."
  1464. (let* ((label (org-element-property :name table))
  1465. (caption (org-e-latex--caption/label-string
  1466. (org-element-property :caption table) label info))
  1467. (attr (mapconcat 'identity
  1468. (org-element-property :attr_latex table)
  1469. " "))
  1470. ;; Determine alignment string.
  1471. (alignment (org-e-latex-table--align-string attr table-info))
  1472. ;; Determine environment for the table: longtable, tabular...
  1473. (table-env (cond
  1474. ((not attr) org-e-latex-default-table-environment)
  1475. ((string-match "\\<longtable\\>" attr) "longtable")
  1476. ((string-match "\\<tabular.?\\>" attr)
  1477. (org-match-string-no-properties 0 attr))
  1478. (t org-e-latex-default-table-environment)))
  1479. ;; If table is a float, determine environment: table or table*.
  1480. (float-env (cond
  1481. ((string= "longtable" table-env) nil)
  1482. ((and attr
  1483. (or (string-match (regexp-quote "table*") attr)
  1484. (string-match "\\<multicolumn\\>" attr)))
  1485. "table*")
  1486. ((or (not (string= caption "")) label) "table")))
  1487. ;; Extract others display options.
  1488. (width (and attr (string-match "\\<width=\\(\\S-+\\)" attr)
  1489. (org-match-string-no-properties 1 attr)))
  1490. (placement
  1491. (if (and attr (string-match "\\<placement=\\(\\S-+\\)" attr))
  1492. (org-match-string-no-properties 1 attr)
  1493. (format "[%s]" org-e-latex-default-figure-position))))
  1494. ;; Prepare the final format string for the table.
  1495. (cond
  1496. ;; Longtable.
  1497. ((string= "longtable" table-env)
  1498. (format
  1499. "\\begin{longtable}{%s}\n%s\n%%s\n%s\\end{longtable}"
  1500. alignment
  1501. (if (or (not org-e-latex-table-caption-above) (string= "" caption)) ""
  1502. (concat (org-trim caption) "\\\\"))
  1503. (if (or org-e-latex-table-caption-above (string= "" caption)) ""
  1504. (concat (org-trim caption) "\\\\\n"))))
  1505. ;; Others.
  1506. (t (concat (when float-env
  1507. (concat
  1508. (format "\\begin{%s}%s\n" float-env placement)
  1509. (if org-e-latex-table-caption-above caption "")))
  1510. (when org-e-latex-tables-centered "\\begin{center}\n")
  1511. (format "\\begin{%s}%s{%s}\n%%s\n\\end{%s}"
  1512. table-env
  1513. (if width (format "{%s}" width) "") alignment table-env)
  1514. (when org-e-latex-tables-centered "\n\\end{center}")
  1515. (when float-env
  1516. (concat (if org-e-latex-table-caption-above "" caption)
  1517. (format "\n\\end{%s}" float-env))))))))
  1518. (defun org-e-latex-table--align-string (attr table-info)
  1519. "Return an appropriate LaTeX alignment string.
  1520. ATTR is a string containing table's LaTeX specific attributes.
  1521. TABLE-INFO is the plist containing format info about the table,
  1522. as returned by `org-export-table-format-info'."
  1523. (or (and attr
  1524. (string-match "\\<align=\\(\\S-+\\)" attr)
  1525. (match-string 1 attr))
  1526. (let* ((align (copy-sequence (plist-get table-info :alignment)))
  1527. (colgroups (copy-sequence (plist-get table-info :column-groups)))
  1528. (cols (length align))
  1529. (separators (make-vector (1+ cols) "")))
  1530. ;; Ignore the first column if it's special.
  1531. (when (plist-get table-info :special-column-p)
  1532. (aset align 0 "") (aset colgroups 0 nil))
  1533. (let ((col 0))
  1534. (mapc (lambda (el)
  1535. (let ((gr (aref colgroups col)))
  1536. (when (memq gr '(start start-end))
  1537. (aset separators col "|"))
  1538. (when (memq gr '(end start-end))
  1539. (aset separators (1+ col) "|")))
  1540. (incf col))
  1541. align))
  1542. ;; Build the LaTeX specific alignment string.
  1543. (loop for al across align
  1544. for sep across separators
  1545. concat (concat sep al) into output
  1546. finally return (concat output (aref separators cols))))))
  1547. (defun org-e-latex-table (table contents info)
  1548. "Transcode a TABLE element from Org to LaTeX.
  1549. CONTENTS is nil. INFO is a plist holding contextual information."
  1550. (let ((attr (mapconcat #'identity
  1551. (org-element-property :attr_latex table)
  1552. " "))
  1553. (raw-table (org-element-property :raw-table table)))
  1554. (cond
  1555. ;; Case 1: verbatim table.
  1556. ((or org-e-latex-tables-verbatim
  1557. (and attr (string-match "\\<verbatim\\>" attr)))
  1558. (format "\\begin{verbatim}\n%s\n\\end{verbatim}"
  1559. (org-export-clean-table
  1560. raw-table
  1561. (plist-get (org-export-table-format-info raw-table)
  1562. :special-column-p))))
  1563. ;; Case 2: table.el table. Convert it using appropriate tools.
  1564. ((eq (org-element-property :type table) 'table.el)
  1565. (require 'table)
  1566. ;; Ensure "*org-export-table*" buffer is empty.
  1567. (with-current-buffer (get-buffer-create "*org-export-table*")
  1568. (erase-buffer))
  1569. (let ((output (with-temp-buffer
  1570. (insert raw-table)
  1571. (goto-char 1)
  1572. (re-search-forward "^[ \t]*|[^|]" nil t)
  1573. (table-generate-source 'latex "*org-export-table*")
  1574. (with-current-buffer "*org-export-table*"
  1575. (org-trim (buffer-string))))))
  1576. (kill-buffer (get-buffer "*org-export-table*"))
  1577. ;; Remove left out comments.
  1578. (while (string-match "^%.*\n" output)
  1579. (setq output (replace-match "" t t output)))
  1580. ;; When the "rmlines" attribute is provided, remove all hlines
  1581. ;; but the the one separating heading from the table body.
  1582. (when (and attr (string-match "\\<rmlines\\>" attr))
  1583. (let ((n 0) (pos 0))
  1584. (while (and (< (length output) pos)
  1585. (setq pos (string-match "^\\\\hline\n?" output pos)))
  1586. (incf n)
  1587. (unless (= n 2)
  1588. (setq output (replace-match "" nil nil output))))))
  1589. (if (not org-e-latex-tables-centered) output
  1590. (format "\\begin{center}\n%s\n\\end{center}" output))))
  1591. ;; Case 3: Standard table.
  1592. (t
  1593. (let* ((table-info (org-export-table-format-info raw-table))
  1594. (columns-number (length (plist-get table-info :alignment)))
  1595. (longtablep (and attr (string-match "\\<longtable\\>" attr)))
  1596. (booktabsp
  1597. (or (and attr (string-match "\\<booktabs=\\(yes\\|t\\)\\>" attr))
  1598. org-e-latex-tables-booktabs))
  1599. ;; CLEAN-TABLE is a table turned into a list, much like
  1600. ;; `org-table-to-lisp', with special column and
  1601. ;; formatting cookies removed, and cells already
  1602. ;; transcoded.
  1603. (clean-table
  1604. (mapcar
  1605. (lambda (row)
  1606. (if (string-match org-table-hline-regexp row) 'hline
  1607. (mapcar
  1608. (lambda (cell)
  1609. (org-export-secondary-string
  1610. (org-element-parse-secondary-string
  1611. cell
  1612. (cdr (assq 'table org-element-string-restrictions)))
  1613. 'e-latex info))
  1614. (org-split-string row "[ \t]*|[ \t]*"))))
  1615. (org-split-string
  1616. (org-export-clean-table
  1617. raw-table (plist-get table-info :special-column-p))
  1618. "\n"))))
  1619. ;; If BOOKTABSP is non-nil, remove any rule at the beginning
  1620. ;; and the end of the table, since booktabs' special rules
  1621. ;; will be inserted instead.
  1622. (when booktabsp
  1623. (when (eq (car clean-table) 'hline)
  1624. (setq clean-table (cdr clean-table)))
  1625. (when (eq (car (last clean-table)) 'hline)
  1626. (setq clean-table (butlast clean-table))))
  1627. ;; Convert ROWS to send them to `orgtbl-to-latex'. In
  1628. ;; particular, send each cell to
  1629. ;; `org-element-parse-secondary-string' to expand any Org
  1630. ;; object within. Eventually, flesh the format string out
  1631. ;; with the table.
  1632. (format
  1633. (org-e-latex-table--format-string table table-info info)
  1634. (orgtbl-to-latex
  1635. clean-table
  1636. ;; Parameters passed to `orgtbl-to-latex'.
  1637. `(:tstart ,(and booktabsp "\\toprule")
  1638. :tend ,(and booktabsp "\\bottomrule")
  1639. :hline ,(if booktabsp "\\midrule" "\\hline")
  1640. ;; Longtable environment requires specific header
  1641. ;; lines end string.
  1642. :hlend ,(and longtablep
  1643. (format "\\\\
  1644. %s
  1645. \\endhead
  1646. %s\\multicolumn{%d}{r}{Continued on next page}\\\\
  1647. \\endfoot
  1648. \\endlastfoot"
  1649. (if booktabsp "\\midrule" "\\hline")
  1650. (if booktabsp "\\midrule" "\\hline")
  1651. columns-number))))))))))
  1652. ;;;; Target
  1653. (defun org-e-latex-target (target text info)
  1654. "Transcode a TARGET object from Org to LaTeX.
  1655. TEXT is the text of the target. INFO is a plist holding
  1656. contextual information."
  1657. (format "\\label{%s}%s"
  1658. (org-export-solidify-link-text
  1659. (org-element-property :raw-value target))
  1660. text))
  1661. ;;;; Time-stamp
  1662. (defun org-e-latex-time-stamp (time-stamp contents info)
  1663. "Transcode a TIME-STAMP object from Org to LaTeX.
  1664. CONTENTS is nil. INFO is a plist holding contextual
  1665. information."
  1666. (let ((value (org-element-property :value time-stamp))
  1667. (type (org-element-property :type time-stamp))
  1668. (appt-type (org-element-property :appt-type time-stamp)))
  1669. (concat (cond ((eq appt-type 'scheduled)
  1670. (format "\\textbf{\\textsc{%s}} " org-scheduled-string))
  1671. ((eq appt-type 'deadline)
  1672. (format "\\textbf{\\textsc{%s}} " org-deadline-string))
  1673. ((eq appt-type 'closed)
  1674. (format "\\textbf{\\textsc{%s}} " org-closed-string)))
  1675. (cond ((memq type '(active active-range))
  1676. (format org-e-latex-active-timestamp-format value))
  1677. ((memq type '(inactive inactive-range))
  1678. (format org-e-latex-inactive-timestamp-format value))
  1679. (t
  1680. (format org-e-latex-diary-timestamp-format value))))))
  1681. ;;;; Verbatim
  1682. (defun org-e-latex-verbatim (verbatim contents info)
  1683. "Transcode a VERBATIM object from Org to LaTeX.
  1684. CONTENTS is nil. INFO is a plist used as a communication
  1685. channel."
  1686. (let ((fmt (cdr (assoc (org-element-property :marker verbatim)
  1687. org-e-latex-emphasis-alist)))
  1688. (value (org-element-property :value verbatim)))
  1689. (cond
  1690. ;; Handle the `verb' special case.
  1691. ((eq 'verb fmt)
  1692. (let ((separator (org-e-latex--find-verb-separator value)))
  1693. (concat "\\verb" separator value separator)))
  1694. ;; Handle the `protectedtexttt' special case.
  1695. ((eq 'protectedtexttt fmt)
  1696. (let ((start 0)
  1697. (trans '(("\\" . "\\textbackslash{}")
  1698. ("~" . "\\textasciitilde{}")
  1699. ("^" . "\\textasciicircum{}")))
  1700. (rtn "")
  1701. char)
  1702. (while (string-match "[\\{}$%&_#~^]" value)
  1703. (setq char (match-string 0 value))
  1704. (if (> (match-beginning 0) 0)
  1705. (setq rtn (concat rtn (substring value 0 (match-beginning 0)))))
  1706. (setq value (substring value (1+ (match-beginning 0))))
  1707. (setq char (or (cdr (assoc char trans)) (concat "\\" char))
  1708. rtn (concat rtn char)))
  1709. (setq value (concat rtn value)
  1710. fmt "\\texttt{%s}")
  1711. (while (string-match "--" value)
  1712. (setq value (replace-match "-{}-" t t value)))
  1713. (format fmt value)))
  1714. ;; Else use format string.
  1715. (t (format fmt value)))))
  1716. ;;;; Verse Block
  1717. (defun org-e-latex-verse-block (verse-block contents info)
  1718. "Transcode a VERSE-BLOCK element from Org to LaTeX.
  1719. CONTENTS is nil. INFO is a plist holding contextual information."
  1720. (org-e-latex--wrap-label
  1721. verse-block
  1722. ;; In a verse environment, add a line break to each newline
  1723. ;; character and change each white space at beginning of a line
  1724. ;; into a space of 1 em. Also change each blank line with
  1725. ;; a vertical space of 1 em.
  1726. (progn
  1727. (setq contents (replace-regexp-in-string
  1728. "^ *\\\\\\\\$" "\\\\vspace*{1em}"
  1729. (replace-regexp-in-string
  1730. "\\(\\\\\\\\\\)?[ \t]*\n" " \\\\\\\\\n"
  1731. (org-remove-indentation
  1732. (org-export-secondary-string
  1733. (org-element-property :value verse-block)
  1734. 'e-latex info)))))
  1735. (while (string-match "^[ \t]+" contents)
  1736. (let ((new-str (format "\\hspace*{%dem}"
  1737. (length (match-string 0 contents)))))
  1738. (setq contents (replace-match new-str nil t contents))))
  1739. (format "\\begin{verse}\n%s\\end{verse}" contents))))
  1740. ;;; Interactive functions
  1741. (defun org-e-latex-export-to-latex
  1742. (&optional subtreep visible-only body-only ext-plist pub-dir)
  1743. "Export current buffer to a LaTeX file.
  1744. If narrowing is active in the current buffer, only export its
  1745. narrowed part.
  1746. If a region is active, export that region.
  1747. When optional argument SUBTREEP is non-nil, export the sub-tree
  1748. at point, extracting information from the headline properties
  1749. first.
  1750. When optional argument VISIBLE-ONLY is non-nil, don't export
  1751. contents of hidden elements.
  1752. When optional argument BODY-ONLY is non-nil, only write code
  1753. between \"\\begin{document}\" and \"\\end{document}\".
  1754. EXT-PLIST, when provided, is a property list with external
  1755. parameters overriding Org default settings, but still inferior to
  1756. file-local settings.
  1757. When optional argument PUB-DIR is set, use it as the publishing
  1758. directory.
  1759. Return output file's name."
  1760. (interactive)
  1761. (let ((outfile (org-export-output-file-name ".tex" subtreep pub-dir)))
  1762. (org-export-to-file
  1763. 'e-latex outfile subtreep visible-only body-only ext-plist)))
  1764. (defun org-e-latex-export-to-pdf
  1765. (&optional subtreep visible-only body-only ext-plist pub-dir)
  1766. "Export current buffer to LaTeX then process through to PDF.
  1767. If narrowing is active in the current buffer, only export its
  1768. narrowed part.
  1769. If a region is active, export that region.
  1770. When optional argument SUBTREEP is non-nil, export the sub-tree
  1771. at point, extracting information from the headline properties
  1772. first.
  1773. When optional argument VISIBLE-ONLY is non-nil, don't export
  1774. contents of hidden elements.
  1775. When optional argument BODY-ONLY is non-nil, only write code
  1776. between \"\\begin{document}\" and \"\\end{document}\".
  1777. EXT-PLIST, when provided, is a property list with external
  1778. parameters overriding Org default settings, but still inferior to
  1779. file-local settings.
  1780. When optional argument PUB-DIR is set, use it as the publishing
  1781. directory.
  1782. Return PDF file's name."
  1783. (interactive)
  1784. (org-e-latex-compile
  1785. (org-e-latex-export-to-latex
  1786. subtreep visible-only body-only ext-plist pub-dir)))
  1787. (defun org-e-latex-compile (texfile)
  1788. "Compile a TeX file.
  1789. TEXFILE is the name of the file being compiled. Processing is
  1790. done through the command specified in `org-e-latex-pdf-process'.
  1791. Return PDF file name or an error if it couldn't be produced."
  1792. (let* ((wconfig (current-window-configuration))
  1793. (texfile (file-truename texfile))
  1794. (base (file-name-sans-extension texfile))
  1795. errors)
  1796. (message (format "Processing LaTeX file %s ..." texfile))
  1797. (unwind-protect
  1798. (progn
  1799. (cond
  1800. ;; A function is provided: Apply it.
  1801. ((functionp org-e-latex-pdf-process)
  1802. (funcall org-e-latex-pdf-process (shell-quote-argument texfile)))
  1803. ;; A list is provided: Replace %b, %f and %o with appropriate
  1804. ;; values in each command before applying it. Output is
  1805. ;; redirected to "*Org PDF LaTeX Output*" buffer.
  1806. ((consp org-e-latex-pdf-process)
  1807. (let* ((out-dir (or (file-name-directory texfile) "./"))
  1808. (outbuf (get-buffer-create "*Org PDF LaTeX Output*")))
  1809. (mapc
  1810. (lambda (command)
  1811. (shell-command
  1812. (replace-regexp-in-string
  1813. "%b" (shell-quote-argument base)
  1814. (replace-regexp-in-string
  1815. "%f" (shell-quote-argument texfile)
  1816. (replace-regexp-in-string
  1817. "%o" (shell-quote-argument out-dir) command t t) t t) t t)
  1818. outbuf))
  1819. org-e-latex-pdf-process)
  1820. ;; Collect standard errors from output buffer.
  1821. (setq errors (org-e-latex-collect-errors outbuf))))
  1822. (t (error "No valid command to process to PDF")))
  1823. (let ((pdffile (concat base ".pdf")))
  1824. ;; Check for process failure. Provide collected errors if
  1825. ;; possible.
  1826. (if (not (file-exists-p pdffile))
  1827. (error (concat (format "PDF file %s wasn't produced" pdffile)
  1828. (when errors (concat ": " errors))))
  1829. ;; Else remove log files, when specified, and signal end of
  1830. ;; process to user, along with any error encountered.
  1831. (when org-e-latex-remove-logfiles
  1832. (dolist (ext org-e-latex-logfiles-extensions)
  1833. (let ((file (concat base "." ext)))
  1834. (when (file-exists-p file) (delete-file file)))))
  1835. (message (concat "Process completed"
  1836. (if (not errors) "."
  1837. (concat " with errors: " errors)))))
  1838. ;; Return output file name.
  1839. pdffile))
  1840. (set-window-configuration wconfig))))
  1841. (defun org-e-latex-collect-errors (buffer)
  1842. "Collect some kind of errors from \"pdflatex\" command output.
  1843. BUFFER is the buffer containing output.
  1844. Return collected error types as a string, or nil if there was
  1845. none."
  1846. (with-current-buffer buffer
  1847. (save-excursion
  1848. (goto-char (point-max))
  1849. ;; Find final "pdflatex" run.
  1850. (when (re-search-backward "^[ \t]*This is pdf.*?TeX.*?Version" nil t)
  1851. (let ((case-fold-search t)
  1852. (errors ""))
  1853. (when (save-excursion
  1854. (re-search-forward "Reference.*?undefined" nil t))
  1855. (setq errors (concat errors " [undefined reference]")))
  1856. (when (save-excursion
  1857. (re-search-forward "Citation.*?undefined" nil t))
  1858. (setq errors (concat errors " [undefined citation]")))
  1859. (when (save-excursion
  1860. (re-search-forward "Undefined control sequence" nil t))
  1861. (setq errors (concat errors " [undefined control sequence]")))
  1862. (when (save-excursion
  1863. (re-search-forward "^! LaTeX.*?Error" nil t))
  1864. (setq errors (concat errors " [LaTeX error]")))
  1865. (when (save-excursion
  1866. (re-search-forward "^! Package.*?Error" nil t))
  1867. (setq errors (concat errors " [package error]")))
  1868. (and (org-string-nw-p errors) (org-trim errors)))))))
  1869. (provide 'org-e-latex)
  1870. ;;; org-e-latex.el ends here