Add the ChangeLog entries
[org-mode/org-tableheadings.git] / lisp / org-latex.el
blobc5cdb3c70fc440c742ef09cfd666874b410a5533
1 ;;; org-latex.el --- LaTeX exporter for org-mode
2 ;;
3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
4 ;;
5 ;; Emacs Lisp Archive Entry
6 ;; Filename: org-latex.el
7 ;; Version: 6.34trans
8 ;; Author: Bastien Guerry <bzg AT altern DOT org>
9 ;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
10 ;; Keywords: org, wp, tex
11 ;; Description: Converts an org-mode buffer into LaTeX
13 ;; This file is part of GNU Emacs.
15 ;; GNU Emacs is free software: you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation, either version 3 of the License, or
18 ;; (at your option) any later version.
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;;; Commentary:
30 ;; This library implements a LaTeX exporter for org-mode.
32 ;; It is part of Org and will be autoloaded
34 ;; The interactive functions are similar to those of the HTML exporter:
36 ;; M-x `org-export-as-latex'
37 ;; M-x `org-export-as-pdf'
38 ;; M-x `org-export-as-pdf-and-open'
39 ;; M-x `org-export-as-latex-batch'
40 ;; M-x `org-export-as-latex-to-buffer'
41 ;; M-x `org-export-region-as-latex'
42 ;; M-x `org-replace-region-by-latex'
44 ;;; Code:
46 (eval-when-compile
47 (require 'cl))
49 (require 'footnote)
50 (require 'org)
51 (require 'org-exp)
52 (require 'org-macs)
53 (require 'org-beamer)
55 ;;; Variables:
56 (defvar org-export-latex-class nil)
57 (defvar org-export-latex-class-options nil)
58 (defvar org-export-latex-header nil)
59 (defvar org-export-latex-append-header nil)
60 (defvar org-export-latex-options-plist nil)
61 (defvar org-export-latex-todo-keywords-1 nil)
62 (defvar org-export-latex-complex-heading-re nil)
63 (defvar org-export-latex-not-done-keywords nil)
64 (defvar org-export-latex-done-keywords nil)
65 (defvar org-export-latex-display-custom-times nil)
66 (defvar org-export-latex-all-targets-re nil)
67 (defvar org-export-latex-add-level 0)
68 (defvar org-export-latex-sectioning "")
69 (defvar org-export-latex-sectioning-depth 0)
70 (defvar org-export-latex-special-keyword-regexp
71 (concat "\\<\\(" org-scheduled-string "\\|"
72 org-deadline-string "\\|"
73 org-closed-string"\\)")
74 "Regexp matching special time planning keywords plus the time after it.")
76 (defvar latexp) ; dynamically scoped from org.el
77 (defvar re-quote) ; dynamically scoped from org.el
78 (defvar commentsp) ; dynamically scoped from org.el
80 ;;; User variables:
82 (defgroup org-export-latex nil
83 "Options for exporting Org-mode files to LaTeX."
84 :tag "Org Export LaTeX"
85 :group 'org-export)
87 (defcustom org-export-latex-default-class "article"
88 "The default LaTeX class."
89 :group 'org-export-latex
90 :type '(string :tag "LaTeX class"))
92 (defcustom org-export-latex-classes
93 '(("article"
94 "\\documentclass[11pt]{article}"
95 ("\\section{%s}" . "\\section*{%s}")
96 ("\\subsection{%s}" . "\\subsection*{%s}")
97 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
98 ("\\paragraph{%s}" . "\\paragraph*{%s}")
99 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
100 ("report"
101 "\\documentclass[11pt]{report}"
102 ("\\part{%s}" . "\\part*{%s}")
103 ("\\chapter{%s}" . "\\chapter*{%s}")
104 ("\\section{%s}" . "\\section*{%s}")
105 ("\\subsection{%s}" . "\\subsection*{%s}")
106 ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
107 ("book"
108 "\\documentclass[11pt]{book}"
109 ("\\part{%s}" . "\\part*{%s}")
110 ("\\chapter{%s}" . "\\chapter*{%s}")
111 ("\\section{%s}" . "\\section*{%s}")
112 ("\\subsection{%s}" . "\\subsection*{%s}")
113 ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
114 ("beamer"
115 "\\documentclass{beamer}"
116 org-beamer-sectioning
118 "Alist of LaTeX classes and associated header and structure.
119 If #+LaTeX_CLASS is set in the buffer, use its value and the
120 associated information. Here is the structure of each cell:
122 \(class-name
123 header-string
124 (numbered-section . unnumbered-section\)
125 ...\)
127 The header string
128 -----------------
130 The HEADER-STRING is the header that will be inserted into the LaTeX file.
131 It should really only contain the contain the \\documentclass macro, and
132 setup code that is specific to this class. This will be augmented by
133 call to \\usepackage for all packages mentioned in the variables
134 `org-export-latex-default-packages-alist' and
135 `org-export-latex-packages-alist'. Lines specified via \"#+LaTeX_HEADER:\"
136 are also added.
137 `org-export-latex-default-packages-alist' contains
138 \"\\usepackage[AUTO]{inputenc}\", AUTO will automatically be replaced with
139 a coding system derived from `buffer-file-coding-system'. See also the
140 variable `org-export-latex-inputenc-alist' for a way to influence this
141 mechanism.
143 The sectioning structure
144 ------------------------
146 The sectioning structure of the class is given by the elements following
147 the header string. For ech sectioning level, a number of strings is
148 specified. A %s formatter is mandatory in each section string and will
149 be replaced by the title of the section.
151 Instead of a cons cell (numbered . unnumbered), you can also provide a list
152 of 2 or 4 elements,
154 (numbered-open numbered-close)
158 (numbered-open numbered-close unnumbered-open unnumbered-close)
160 providing opening and closing strings for an environment that should
161 represent the document section. The opening clause should have a %s
162 to represent the section title.
164 Instead of a list of sectioning commands, you can also specify a
165 function name. That function will be called with two parameters,
166 the (reduced) level of the headline, and the headline text. The functions
167 returns a cons cell with the (possibly modified) headline text, and the
168 sectioning list in the cdr."
169 :group 'org-export-latex
170 :type '(repeat
171 (list (string :tag "LaTeX class")
172 (string :tag "LaTeX header")
173 (repeat :tag "Levels" :inline t
174 (choice
175 (cons :tag "Heading"
176 (string :tag " numbered")
177 (string :tag "unnumbered"))
178 (list :tag "Environment"
179 (string :tag "Opening (numbered)")
180 (string :tag "Closing (numbered)")
181 (string :tag "Opening (unnumbered)")
182 (string :tag "Closing (unnumbered)"))
183 (function :tag "Hook computing sectioning"))))))
185 (defcustom org-export-latex-inputenc-alist nil
186 "Alist of inputenc coding system names, and what should really be used.
187 For example, adding an entry
189 (\"utf8\" . \"utf8x\")
191 will cause \\usepackage[utf8x]{inputenc} to be used for buffers that
192 are written as utf8 files."
193 :group 'org-export-latex
194 :type '(repeat
195 (cons
196 (string :tag "Derived from buffer")
197 (string :tag "Use this instead"))))
200 (defcustom org-export-latex-emphasis-alist
201 '(("*" "\\textbf{%s}" nil)
202 ("/" "\\emph{%s}" nil)
203 ("_" "\\underline{%s}" nil)
204 ("+" "\\st{%s}" nil)
205 ("=" "\\verb" t)
206 ("~" "\\verb" t))
207 "Alist of LaTeX expressions to convert emphasis fontifiers.
208 Each element of the list is a list of three elements.
209 The first element is the character used as a marker for fontification.
210 The second element is a formatting string to wrap fontified text with.
211 If it is \"\\verb\", Org will automatically select a delimiter
212 character that is not in the string.
213 The third element decides whether to protect converted text from other
214 conversions."
215 :group 'org-export-latex
216 :type 'alist)
218 (defcustom org-export-latex-title-command "\\maketitle"
219 "The command used to insert the title just after \\begin{document}.
220 If this string contains the formatting specification \"%s\" then
221 it will be used as a formatting string, passing the title as an
222 argument."
223 :group 'org-export-latex
224 :type 'string)
226 (defcustom org-export-latex-import-inbuffer-stuff nil
227 "Non-nil means define TeX macros for Org's inbuffer definitions.
228 For example \orgTITLE for #+TITLE."
229 :group 'org-export-latex
230 :type 'boolean)
232 (defcustom org-export-latex-date-format
233 "%d %B %Y"
234 "Format string for \\date{...}."
235 :group 'org-export-latex
236 :type 'string)
238 (defcustom org-export-latex-todo-keyword-markup "\\textbf{%s}"
239 "Markup for TODO keywords, as a printf format.
240 This can be a single format for all keywords, a cons cell with separate
241 formats for not-done and done states, or an association list with setup
242 for individual keywords. If a keyword shows up for which there is no
243 markup defined, the first one in the association list will be used."
244 :group 'org-export-latex
245 :type '(choice
246 (string :tag "Default")
247 (cons :tag "Distinguish undone and done"
248 (string :tag "Not-DONE states")
249 (string :tag "DONE states"))
250 (repeat :tag "Per keyword markup"
251 (cons
252 (string :tag "Keyword")
253 (string :tag "Markup")))))
255 (defcustom org-export-latex-timestamp-markup "\\textit{%s}"
256 "A printf format string to be applied to time stamps."
257 :group 'org-export-latex
258 :type 'string)
260 (defcustom org-export-latex-timestamp-keyword-markup "\\texttt{%s}"
261 "A printf format string to be applied to time stamps."
262 :group 'org-export-latex
263 :type 'string)
265 (defcustom org-export-latex-hyperref-format "\\href{%s}{%s}"
266 "A printf format string to be applied to hyperref links.
267 The format must contain two %s instances. The first will be filled with
268 the link, the second with the link description."
269 :group 'org-export-latex
270 :type 'string)
272 (defcustom org-export-latex-tables-verbatim nil
273 "When non-nil, tables are exported verbatim."
274 :group 'org-export-latex
275 :type 'boolean)
277 (defcustom org-export-latex-tables-centered t
278 "When non-nil, tables are exported in a center environment."
279 :group 'org-export-latex
280 :type 'boolean)
282 (defcustom org-export-latex-tables-column-borders nil
283 "When non-nil, grouping columns can cause outer vertical lines in tables.
284 When nil, grouping causes only separation lines between groups."
285 :group 'org-export-latex
286 :type 'boolean)
288 (defcustom org-export-latex-low-levels 'itemize
289 "How to convert sections below the current level of sectioning.
290 This is specified by the `org-export-headline-levels' option or the
291 value of \"H:\" in Org's #+OPTION line.
293 This can be either nil (skip the sections), `description', `itemize',
294 or `enumerate' (convert the sections as the corresponding list type), or
295 a string to be used instead of \\section{%s}. In this latter case,
296 the %s stands here for the inserted headline and is mandatory.
298 It may also be a list of three string to define a user-defined environment
299 that should be used. The first string should be the like
300 \"\\begin{itemize}\", the second should be like \"\\item %s %s\" with up
301 to two occurrences of %s for the title and a label, respectively. The third
302 string should be like \"\\end{itemize\"."
303 :group 'org-export-latex
304 :type '(choice (const :tag "Ignore" nil)
305 (const :tag "Convert as descriptive list" description)
306 (const :tag "Convert as itemized list" itemize)
307 (const :tag "Convert as enumerated list" enumerate)
308 (list :tag "User-defined environment"
309 :value ("\\begin{itemize}" "\\end{itemize}" "\\item %s")
310 (string :tag "Start")
311 (string :tag "End")
312 (string :tag "item"))
313 (string :tag "Use a section string" :value "\\subparagraph{%s}")))
315 (defcustom org-export-latex-list-parameters
316 '(:cbon "$\\boxtimes$" :cboff "$\\Box$")
317 "Parameters for the LaTeX list exporter.
318 These parameters will be passed on to `org-list-to-latex', which in turn
319 will pass them (combined with the LaTeX default list parameters) to
320 `org-list-to-generic'."
321 :group 'org-export-latex
322 :type 'plist)
324 (defcustom org-export-latex-verbatim-wrap
325 '("\\begin{verbatim}\n" . "\\end{verbatim}\n")
326 "Environment to be wrapped around a fixed-width section in LaTeX export.
327 This is a cons with two strings, to be added before and after the
328 fixed-with text.
330 Defaults to \\begin{verbatim} and \\end{verbatim}."
331 :group 'org-export-translation
332 :group 'org-export-latex
333 :type '(cons (string :tag "Open")
334 (string :tag "Close")))
336 (defcustom org-export-latex-listings nil
337 "Non-nil means export source code using the listings package.
338 This package will fontify source code, possibly even with color.
339 If you want to use this, you also need to make LaTeX use the
340 listings package, and if you want to have color, the color
341 package. Just add these to `org-export-latex-packages-alist',
342 for example using customize, or with something like
344 (require 'org-latex)
345 (add-to-list 'org-export-latex-packages-alist '(\"\" \"listings\"))
346 (add-to-list 'org-export-latex-packages-alist '(\"\" \"color\"))"
347 :group 'org-export-latex
348 :type 'boolean)
350 (defcustom org-export-latex-listings-langs
351 '((emacs-lisp "Lisp") (lisp "Lisp")
352 (c "C") (cc "C++")
353 (fortran "fortran")
354 (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby")
355 (html "HTML") (xml "XML")
356 (tex "TeX") (latex "TeX")
357 (shell-script "bash")
358 (gnuplot "Gnuplot")
359 (ocaml "Caml") (caml "Caml")
360 (sql "SQL"))
361 "Alist mapping languages to their listing language counterpart.
362 The key is a symbol, the major mode symbol without the \"-mode\".
363 The value is the string that should be inserted as the language parameter
364 for the listings package. If the mode name and the listings name are
365 the same, the language does not need an entry in this list - but it does not
366 hurt if it is present."
367 :group 'org-export-latex
368 :type '(repeat
369 (list
370 (symbol :tag "Major mode ")
371 (string :tag "Listings language"))))
373 (defcustom org-export-latex-remove-from-headlines
374 '(:todo nil :priority nil :tags nil)
375 "A plist of keywords to remove from headlines. OBSOLETE.
376 Non-nil means remove this keyword type from the headline.
378 Don't remove the keys, just change their values.
380 Obsolete, this variable is no longer used. Use the separate
381 variables `org-export-with-todo-keywords', `org-export-with-priority',
382 and `org-export-with-tags' instead."
383 :type 'plist
384 :group 'org-export-latex)
386 (defcustom org-export-latex-image-default-option "width=10em"
387 "Default option for images."
388 :group 'org-export-latex
389 :type 'string)
391 (defcustom org-export-latex-inline-image-extensions
392 '("pdf" "jpeg" "jpg" "png" "ps" "eps")
393 "Extensions of image files that can be inlined into LaTeX.
394 Note that the image extension *actually* allowed depend on the way the
395 LaTeX file is processed. When used with pdflatex, pdf, jpg and png images
396 are OK. When processing through dvi to Postscript, only ps and eps are
397 allowed. The default we use here encompasses both."
398 :group 'org-export-latex
399 :type '(repeat (string :tag "Extension")))
401 (defcustom org-export-latex-coding-system nil
402 "Coding system for the exported LaTex file."
403 :group 'org-export-latex
404 :type 'coding-system)
406 (defgroup org-export-pdf nil
407 "Options for exporting Org-mode files to PDF, via LaTeX."
408 :tag "Org Export PDF"
409 :group 'org-export-latex
410 :group 'org-export)
412 (defcustom org-latex-to-pdf-process
413 '("pdflatex -interaction nonstopmode %s"
414 "pdflatex -interaction nonstopmode %s")
415 "Commands to process a LaTeX file to a PDF file.
416 This is a list of strings, each of them will be given to the shell
417 as a command. %s in the command will be replaced by the full file name, %b
418 by the file base name (i.e. without extension).
419 The reason why this is a list is that it usually takes several runs of
420 pdflatex, maybe mixed with a call to bibtex. Org does not have a clever
421 mechanism to detect which of these commands have to be run to get to a stable
422 result, and it also does not do any error checking.
424 Alternatively, this may be a Lisp function that does the processing, so you
425 could use this to apply the machinery of AUCTeX or the Emacs LaTeX mode.
426 This function should accept the file name as its single argument."
427 :group 'org-export-pdf
428 :type '(choice (repeat :tag "Shell command sequence"
429 (string :tag "Shell command"))
430 (function)))
432 (defcustom org-export-pdf-logfiles
433 '("aux" "idx" "log" "out" "toc" "nav" "snm" "vrb")
434 "The list of file extensions to consider as LaTeX logfiles."
435 :group 'org-export-pdf
436 :type '(repeat (string :tag "Extension")))
438 (defcustom org-export-pdf-remove-logfiles t
439 "Non-nil means remove the logfiles produced by PDF production.
440 These are the .aux, .log, .out, and .toc files."
441 :group 'org-export-pdf
442 :type 'boolean)
444 ;;; Hooks
446 (defvar org-export-latex-after-initial-vars-hook nil
447 "Hook run before LaTeX export.
448 The exact moment is after the initial variables like org-export-latex-class
449 have been determined from the environment.")
451 (defvar org-export-latex-after-blockquotes-hook nil
452 "Hook run during LaTeX export, after blockquote, verse, center are done.")
454 (defvar org-export-latex-final-hook nil
455 "Hook run in the finalized LaTeX buffer.")
457 (defvar org-export-latex-after-save-hook nil
458 "Hook run in the finalized LaTeX buffer, after it has been saved.")
460 ;;; Autoload functions:
462 ;;;###autoload
463 (defun org-export-as-latex-batch ()
464 "Call `org-export-as-latex', may be used in batch processing.
465 For example:
467 emacs --batch
468 --load=$HOME/lib/emacs/org.el
469 --eval \"(setq org-export-headline-levels 2)\"
470 --visit=MyFile --funcall org-export-as-latex-batch"
471 (org-export-as-latex org-export-headline-levels 'hidden))
473 ;;;###autoload
474 (defun org-export-as-latex-to-buffer (arg)
475 "Call `org-export-as-latex` with output to a temporary buffer.
476 No file is created. The prefix ARG is passed through to `org-export-as-latex'."
477 (interactive "P")
478 (org-export-as-latex arg nil nil "*Org LaTeX Export*")
479 (when org-export-show-temporary-export-buffer
480 (switch-to-buffer-other-window "*Org LaTeX Export*")))
482 ;;;###autoload
483 (defun org-replace-region-by-latex (beg end)
484 "Replace the region from BEG to END with its LaTeX export.
485 It assumes the region has `org-mode' syntax, and then convert it to
486 LaTeX. This can be used in any buffer. For example, you could
487 write an itemized list in `org-mode' syntax in an LaTeX buffer and
488 then use this command to convert it."
489 (interactive "r")
490 (let (reg latex buf)
491 (save-window-excursion
492 (if (org-mode-p)
493 (setq latex (org-export-region-as-latex
494 beg end t 'string))
495 (setq reg (buffer-substring beg end)
496 buf (get-buffer-create "*Org tmp*"))
497 (with-current-buffer buf
498 (erase-buffer)
499 (insert reg)
500 (org-mode)
501 (setq latex (org-export-region-as-latex
502 (point-min) (point-max) t 'string)))
503 (kill-buffer buf)))
504 (delete-region beg end)
505 (insert latex)))
507 ;;;###autoload
508 (defun org-export-region-as-latex (beg end &optional body-only buffer)
509 "Convert region from BEG to END in `org-mode' buffer to LaTeX.
510 If prefix arg BODY-ONLY is set, omit file header, footer, and table of
511 contents, and only produce the region of converted text, useful for
512 cut-and-paste operations.
513 If BUFFER is a buffer or a string, use/create that buffer as a target
514 of the converted LaTeX. If BUFFER is the symbol `string', return the
515 produced LaTeX as a string and leave no buffer behind. For example,
516 a Lisp program could call this function in the following way:
518 (setq latex (org-export-region-as-latex beg end t 'string))
520 When called interactively, the output buffer is selected, and shown
521 in a window. A non-interactive call will only return the buffer."
522 (interactive "r\nP")
523 (when (interactive-p)
524 (setq buffer "*Org LaTeX Export*"))
525 (let ((transient-mark-mode t) (zmacs-regions t)
526 ext-plist rtn)
527 (setq ext-plist (plist-put ext-plist :ignore-subtree-p t))
528 (goto-char end)
529 (set-mark (point)) ;; to activate the region
530 (goto-char beg)
531 (setq rtn (org-export-as-latex
532 nil nil ext-plist
533 buffer body-only))
534 (if (fboundp 'deactivate-mark) (deactivate-mark))
535 (if (and (interactive-p) (bufferp rtn))
536 (switch-to-buffer-other-window rtn)
537 rtn)))
539 ;;;###autoload
540 (defun org-export-as-latex (arg &optional hidden ext-plist
541 to-buffer body-only pub-dir)
542 "Export current buffer to a LaTeX file.
543 If there is an active region, export only the region. The prefix
544 ARG specifies how many levels of the outline should become
545 headlines. The default is 3. Lower levels will be exported
546 depending on `org-export-latex-low-levels'. The default is to
547 convert them as description lists.
548 HIDDEN is obsolete and does nothing.
549 EXT-PLIST is a property list with
550 external parameters overriding org-mode's default settings, but
551 still inferior to file-local settings. When TO-BUFFER is
552 non-nil, create a buffer with that name and export to that
553 buffer. If TO-BUFFER is the symbol `string', don't leave any
554 buffer behind but just return the resulting LaTeX as a string.
555 When BODY-ONLY is set, don't produce the file header and footer,
556 simply return the content of \begin{document}...\end{document},
557 without even the \begin{document} and \end{document} commands.
558 when PUB-DIR is set, use this as the publishing directory."
559 (interactive "P")
560 (run-hooks 'org-export-first-hook)
562 ;; Make sure we have a file name when we need it.
563 (when (and (not (or to-buffer body-only))
564 (not buffer-file-name))
565 (if (buffer-base-buffer)
566 (org-set-local 'buffer-file-name
567 (with-current-buffer (buffer-base-buffer)
568 buffer-file-name))
569 (error "Need a file name to be able to export")))
571 (message "Exporting to LaTeX...")
572 (org-unmodified
573 (let ((inhibit-read-only t))
574 (remove-text-properties (point-min) (point-max)
575 '(:org-license-to-kill nil))))
576 (org-update-radio-target-regexp)
577 (org-export-latex-set-initial-vars ext-plist arg)
578 (setq org-export-opt-plist org-export-latex-options-plist)
579 (org-install-letbind)
580 (run-hooks 'org-export-latex-after-initial-vars-hook)
581 (let* ((wcf (current-window-configuration))
582 (opt-plist org-export-latex-options-plist)
583 (region-p (org-region-active-p))
584 (rbeg (and region-p (region-beginning)))
585 (rend (and region-p (region-end)))
586 (subtree-p
587 (if (plist-get opt-plist :ignore-subtree-p)
589 (when region-p
590 (save-excursion
591 (goto-char rbeg)
592 (and (org-at-heading-p)
593 (>= (org-end-of-subtree t t) rend))))))
594 (opt-plist (setq org-export-opt-plist
595 (if subtree-p
596 (org-export-add-subtree-options opt-plist rbeg)
597 opt-plist)))
598 ;; Make sure the variable contains the updated values.
599 (org-export-latex-options-plist (setq org-export-opt-plist opt-plist))
600 ;; The following two are dynamically scoped into other
601 ;; routines below.
602 (org-current-export-dir
603 (or pub-dir (org-export-directory :html opt-plist)))
604 (org-current-export-file buffer-file-name)
605 (title (or (and subtree-p (org-export-get-title-from-subtree))
606 (plist-get opt-plist :title)
607 (and (not
608 (plist-get opt-plist :skip-before-1st-heading))
609 (org-export-grab-title-from-buffer))
610 (and buffer-file-name
611 (file-name-sans-extension
612 (file-name-nondirectory buffer-file-name)))
613 "No Title"))
614 (filename
615 (and (not to-buffer)
616 (concat
617 (file-name-as-directory
618 (or pub-dir
619 (org-export-directory :LaTeX ext-plist)))
620 (file-name-sans-extension
621 (or (and subtree-p
622 (org-entry-get rbeg "EXPORT_FILE_NAME" t))
623 (file-name-nondirectory ;sans-extension
624 (or buffer-file-name
625 (error "Don't know which export file to use.")))))
626 ".tex")))
627 (filename
628 (and filename
629 (if (equal (file-truename filename)
630 (file-truename (or buffer-file-name "dummy.org")))
631 (concat filename ".tex")
632 filename)))
633 (buffer (if to-buffer
634 (cond
635 ((eq to-buffer 'string) (get-buffer-create
636 "*Org LaTeX Export*"))
637 (t (get-buffer-create to-buffer)))
638 (find-file-noselect filename)))
639 (odd org-odd-levels-only)
640 (header (org-export-latex-make-header title opt-plist))
641 (skip (cond (subtree-p nil)
642 (region-p nil)
643 (t (plist-get opt-plist :skip-before-1st-heading))))
644 (text (plist-get opt-plist :text))
645 (org-export-preprocess-hook
646 (cons
647 `(lambda () (org-set-local 'org-complex-heading-regexp
648 ,org-export-latex-complex-heading-re))
649 org-export-preprocess-hook))
650 (first-lines (if skip "" (org-export-latex-first-lines
651 opt-plist
652 (if subtree-p
653 (save-excursion
654 (goto-char rbeg)
655 (point-at-bol 2))
656 rbeg)
657 (if region-p rend))))
658 (coding-system (and (boundp 'buffer-file-coding-system)
659 buffer-file-coding-system))
660 (coding-system-for-write (or org-export-latex-coding-system
661 coding-system))
662 (save-buffer-coding-system (or org-export-latex-coding-system
663 coding-system))
664 (region (buffer-substring
665 (if region-p (region-beginning) (point-min))
666 (if region-p (region-end) (point-max))))
667 (text
668 (and text (string-match "\\S-" text)
669 (org-export-preprocess-string
670 text
671 :emph-multiline t
672 :for-LaTeX t
673 :comments nil
674 :tags (plist-get opt-plist :tags)
675 :priority (plist-get opt-plist :priority)
676 :footnotes (plist-get opt-plist :footnotes)
677 :drawers (plist-get opt-plist :drawers)
678 :timestamps (plist-get opt-plist :timestamps)
679 :todo-keywords (plist-get opt-plist :todo-keywords)
680 :add-text nil
681 :skip-before-1st-heading skip
682 :select-tags nil
683 :exclude-tags nil
684 :LaTeX-fragments nil)))
685 (string-for-export
686 (org-export-preprocess-string
687 region
688 :emph-multiline t
689 :for-LaTeX t
690 :comments nil
691 :tags (plist-get opt-plist :tags)
692 :priority (plist-get opt-plist :priority)
693 :footnotes (plist-get opt-plist :footnotes)
694 :drawers (plist-get opt-plist :drawers)
695 :timestamps (plist-get opt-plist :timestamps)
696 :todo-keywords (plist-get opt-plist :todo-keywords)
697 :add-text (if (eq to-buffer 'string) nil text)
698 :skip-before-1st-heading skip
699 :select-tags (plist-get opt-plist :select-tags)
700 :exclude-tags (plist-get opt-plist :exclude-tags)
701 :LaTeX-fragments nil)))
703 (set-buffer buffer)
704 (erase-buffer)
705 (org-install-letbind)
707 (and (fboundp 'set-buffer-file-coding-system)
708 (set-buffer-file-coding-system coding-system-for-write))
710 ;; insert the header and initial document commands
711 (unless (or (eq to-buffer 'string) body-only)
712 (insert header))
714 ;; insert text found in #+TEXT
715 (when (and text (not (eq to-buffer 'string)))
716 (insert (org-export-latex-content
717 text '(lists tables fixed-width keywords))
718 "\n\n"))
720 ;; insert lines before the first headline
721 (unless skip
722 (insert first-lines))
724 ;; export the content of headlines
725 (org-export-latex-global
726 (with-temp-buffer
727 (insert string-for-export)
728 (goto-char (point-min))
729 (when (re-search-forward "^\\(\\*+\\) " nil t)
730 (let* ((asters (length (match-string 1)))
731 (level (if odd (- asters 2) (- asters 1))))
732 (setq org-export-latex-add-level
733 (if odd (1- (/ (1+ asters) 2)) (1- asters)))
734 (org-export-latex-parse-global level odd)))))
736 ;; finalization
737 (unless body-only (insert "\n\\end{document}"))
739 ;; Attach description terms to the \item macro
740 (goto-char (point-min))
741 (while (re-search-forward "^[ \t]*\\\\item\\([ \t]+\\)\\[" nil t)
742 (delete-region (match-beginning 1) (match-end 1)))
744 ;; Relocate the table of contents
745 (goto-char (point-min))
746 (when (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t)
747 (goto-char (point-min))
748 (while (re-search-forward "\\\\tableofcontents\\>[ \t]*\n?" nil t)
749 (replace-match ""))
750 (goto-char (point-min))
751 (and (re-search-forward "\\[TABLE-OF-CONTENTS\\]" nil t)
752 (replace-match "\\tableofcontents" t t)))
754 ;; Cleanup forced line ends in items where they are not needed
755 (goto-char (point-min))
756 (while (re-search-forward
757 "^[ \t]*\\\\item\\>.*\\(\\\\\\\\\\)[ \t]*\\(\n\\\\label.*\\)*\n\\\\begin"
758 nil t)
759 (delete-region (match-beginning 1) (match-end 1)))
760 (goto-char (point-min))
761 (while (re-search-forward
762 "^[ \t]*\\\\item\\>.*\\(\\\\\\\\\\)[ \t]*\\(\n\\\\label.*\\)*"
763 nil t)
764 (if (looking-at "[\n \t]+")
765 (replace-match "\n")))
767 (run-hooks 'org-export-latex-final-hook)
768 (or to-buffer (save-buffer))
769 (org-export-latex-fix-inputenc)
770 (run-hooks 'org-export-latex-after-save-hook)
771 (goto-char (point-min))
772 (or (org-export-push-to-kill-ring "LaTeX")
773 (message "Exporting to LaTeX...done"))
774 (prog1
775 (if (eq to-buffer 'string)
776 (prog1 (buffer-substring (point-min) (point-max))
777 (kill-buffer (current-buffer)))
778 (current-buffer))
779 (set-window-configuration wcf))))
781 ;;;###autoload
782 (defun org-export-as-pdf (arg &optional hidden ext-plist
783 to-buffer body-only pub-dir)
784 "Export as LaTeX, then process through to PDF."
785 (interactive "P")
786 (message "Exporting to PDF...")
787 (let* ((wconfig (current-window-configuration))
788 (lbuf (org-export-as-latex arg hidden ext-plist
789 to-buffer body-only pub-dir))
790 (file (buffer-file-name lbuf))
791 (base (file-name-sans-extension (buffer-file-name lbuf)))
792 (pdffile (concat base ".pdf"))
793 (cmds org-latex-to-pdf-process)
794 (outbuf (get-buffer-create "*Org PDF LaTeX Output*"))
795 (bibtex-p (with-current-buffer lbuf
796 (save-excursion
797 (goto-char (point-min))
798 (re-search-forward "\\\\bibliography{" nil t))))
799 cmd)
800 (with-current-buffer outbuf (erase-buffer))
801 (message "Processing LaTeX file...")
802 (if (and cmds (symbolp cmds))
803 (funcall cmds file)
804 (while cmds
805 (setq cmd (pop cmds))
806 (while (string-match "%b" cmd)
807 (setq cmd (replace-match
808 (save-match-data
809 (shell-quote-argument base))
810 t t cmd)))
811 (while (string-match "%s" cmd)
812 (setq cmd (replace-match
813 (save-match-data
814 (shell-quote-argument file))
815 t t cmd)))
816 (shell-command cmd outbuf outbuf)))
817 (message "Processing LaTeX file...done")
818 (if (not (file-exists-p pdffile))
819 (error "PDF file was not produced")
820 (set-window-configuration wconfig)
821 (when org-export-pdf-remove-logfiles
822 (dolist (ext org-export-pdf-logfiles)
823 (setq file (concat base "." ext))
824 (and (file-exists-p file) (delete-file file))))
825 (message "Exporting to PDF...done")
826 pdffile)))
828 ;;;###autoload
829 (defun org-export-as-pdf-and-open (arg)
830 "Export as LaTeX, then process through to PDF, and open."
831 (interactive "P")
832 (let ((pdffile (org-export-as-pdf arg)))
833 (if pdffile
834 (progn
835 (org-open-file pdffile)
836 (when org-export-kill-product-buffer-when-displayed
837 (kill-buffer (find-buffer-visiting
838 (concat (file-name-sans-extension (buffer-file-name))
839 ".tex")))))
840 (error "PDF file was not produced"))))
842 ;;; Parsing functions:
844 (defun org-export-latex-parse-global (level odd)
845 "Parse the current buffer recursively, starting at LEVEL.
846 If ODD is non-nil, assume the buffer only contains odd sections.
847 Return a list reflecting the document structure."
848 (save-excursion
849 (goto-char (point-min))
850 (let* ((cnt 0) output
851 (depth org-export-latex-sectioning-depth))
852 (while (org-re-search-forward-unprotected
853 (concat "^\\(\\(?:\\*\\)\\{"
854 (number-to-string (+ (if odd 2 1) level))
855 "\\}\\) \\(.*\\)$")
856 ;; make sure that there is no upper heading
857 (when (> level 0)
858 (save-excursion
859 (save-match-data
860 (org-re-search-forward-unprotected
861 (concat "^\\(\\(?:\\*\\)\\{"
862 (number-to-string level)
863 "\\}\\) \\(.*\\)$") nil t)))) t)
864 (setq cnt (1+ cnt))
865 (let* ((pos (match-beginning 0))
866 (heading (match-string 2))
867 (nlevel (if odd (/ (+ 3 level) 2) (1+ level))))
868 (save-excursion
869 (narrow-to-region
870 (point)
871 (save-match-data
872 (if (org-re-search-forward-unprotected
873 (concat "^\\(\\(?:\\*\\)\\{"
874 (number-to-string (+ (if odd 2 1) level))
875 "\\}\\) \\(.*\\)$") nil t)
876 (match-beginning 0)
877 (point-max))))
878 (goto-char (point-min))
879 (setq output
880 (append output
881 (list
882 (list
883 `(pos . ,pos)
884 `(level . ,nlevel)
885 `(occur . ,cnt)
886 `(heading . ,heading)
887 `(content . ,(org-export-latex-parse-content))
888 `(subcontent . ,(org-export-latex-parse-subcontent
889 level odd)))))))
890 (widen)))
891 (list output))))
893 (defun org-export-latex-parse-content ()
894 "Extract the content of a section."
895 (let ((beg (point))
896 (end (if (org-re-search-forward-unprotected "^\\(\\*\\)+ .*$" nil t)
897 (progn (beginning-of-line) (point))
898 (point-max))))
899 (buffer-substring beg end)))
901 (defun org-export-latex-parse-subcontent (level odd)
902 "Extract the subcontent of a section at LEVEL.
903 If ODD Is non-nil, assume subcontent only contains odd sections."
904 (if (not (org-re-search-forward-unprotected
905 (concat "^\\(\\(?:\\*\\)\\{"
906 (number-to-string (+ (if odd 4 2) level))
907 "\\}\\) \\(.*\\)$")
908 nil t))
909 nil ; subcontent is nil
910 (org-export-latex-parse-global (+ (if odd 2 1) level) odd)))
912 ;;; Rendering functions:
913 (defun org-export-latex-global (content)
914 "Export CONTENT to LaTeX.
915 CONTENT is an element of the list produced by
916 `org-export-latex-parse-global'."
917 (if (eq (car content) 'subcontent)
918 (mapc 'org-export-latex-sub (cdr content))
919 (org-export-latex-sub (car content))))
921 (defun org-export-latex-sub (subcontent)
922 "Export the list SUBCONTENT to LaTeX.
923 SUBCONTENT is an alist containing information about the headline
924 and its content."
925 (let ((num (plist-get org-export-latex-options-plist :section-numbers)))
926 (mapc (lambda(x) (org-export-latex-subcontent x num)) subcontent)))
928 (defun org-export-latex-subcontent (subcontent num)
929 "Export each cell of SUBCONTENT to LaTeX.
930 If NUM, export sections as numerical sections."
931 (let* ((heading (cdr (assoc 'heading subcontent)))
932 (level (- (cdr (assoc 'level subcontent))
933 org-export-latex-add-level))
934 (occur (number-to-string (cdr (assoc 'occur subcontent))))
935 (content (cdr (assoc 'content subcontent)))
936 (subcontent (cadr (assoc 'subcontent subcontent)))
937 (label (org-get-text-property-any 0 'target heading))
938 (label-list (cons label (cdr (assoc label
939 org-export-target-aliases))))
940 (sectioning org-export-latex-sectioning)
941 (depth org-export-latex-sectioning-depth)
942 main-heading sub-heading)
943 (when (symbolp (car sectioning))
944 (setq sectioning (funcall (car sectioning) level heading))
945 (when sectioning
946 (setq heading (car sectioning)
947 sectioning (cdr sectioning)
948 ;; target property migh have changed...
949 label (org-get-text-property-any 0 'target heading)
950 label-list (cons label (cdr (assoc label
951 org-export-target-aliases)))))
952 (if sectioning (setq sectioning (make-list 10 sectioning)))
953 (setq depth (if sectioning 10000 0)))
954 (if (string-match "[ \t]*\\\\\\\\[ \t]*" heading)
955 (setq main-heading (substring heading 0 (match-beginning 0))
956 sub-heading (substring heading (match-end 0))))
957 (setq heading (org-export-latex-fontify-headline heading)
958 sub-heading (and sub-heading
959 (org-export-latex-fontify-headline sub-heading))
960 main-heading (and main-heading
961 (org-export-latex-fontify-headline main-heading)))
962 (cond
963 ;; Normal conversion
964 ((<= level depth)
965 (let* ((sec (nth (1- level) sectioning))
966 start end)
967 (if (consp (cdr sec))
968 (setq start (nth (if num 0 2) sec)
969 end (nth (if num 1 3) sec))
970 (setq start (if num (car sec) (cdr sec))))
971 (insert (format start (if main-heading main-heading heading)
972 (or sub-heading "")))
973 (insert "\n")
974 (when label
975 (insert (mapconcat (lambda (l) (format "\\label{%s}" l))
976 label-list "\n") "\n"))
977 (insert (org-export-latex-content content))
978 (cond ((stringp subcontent) (insert subcontent))
979 ((listp subcontent)
980 (while (org-looking-back "\n\n") (backward-delete-char 1))
981 (org-export-latex-sub subcontent)))
982 (when (and end (string-match "[^ \t]" end))
983 (let ((hook (org-get-text-property-any 0 'org-insert-hook end)))
984 (and (functionp hook) (funcall hook)))
985 (insert end "\n"))))
986 ;; At a level under the hl option: we can drop this subsection
987 ((> level depth)
988 (cond ((eq org-export-latex-low-levels 'description)
989 (if (string-match "% ends low level$"
990 (buffer-substring (point-at-bol 0) (point)))
991 (delete-region (point-at-bol 0) (point))
992 (insert "\\begin{description}\n"))
993 (insert (format "\n\\item[%s]%s~\n"
994 heading
995 (if label (format "\\label{%s}" label) "")))
996 (insert (org-export-latex-content content))
997 (cond ((stringp subcontent) (insert subcontent))
998 ((listp subcontent) (org-export-latex-sub subcontent)))
999 (insert "\\end{description} % ends low level\n"))
1000 ((memq org-export-latex-low-levels '(itemize enumerate))
1001 (if (string-match "% ends low level$"
1002 (buffer-substring (point-at-bol 0) (point)))
1003 (delete-region (point-at-bol 0) (point))
1004 (insert (format "\\begin{%s}\n"
1005 (symbol-name org-export-latex-low-levels))))
1006 (insert (format "\n\\item %s\\\\\n%s%%"
1007 heading
1008 (if label (format "\\label{%s}" label) "")))
1009 (insert (org-export-latex-content content))
1010 (cond ((stringp subcontent) (insert subcontent))
1011 ((listp subcontent) (org-export-latex-sub subcontent)))
1012 (insert (format "\\end{%s} %% ends low level\n"
1013 (symbol-name org-export-latex-low-levels))))
1015 ((listp org-export-latex-low-levels)
1016 (if (string-match "% ends low level$"
1017 (buffer-substring (point-at-bol 0) (point)))
1018 (delete-region (point-at-bol 0) (point))
1019 (insert (car org-export-latex-low-levels) "\n"))
1020 (insert (format (nth 2 org-export-latex-low-levels)
1021 heading
1022 (if label (format "\\label{%s}" label) "")))
1023 (insert (org-export-latex-content content))
1024 (cond ((stringp subcontent) (insert subcontent))
1025 ((listp subcontent) (org-export-latex-sub subcontent)))
1026 (insert (nth 1 org-export-latex-low-levels)
1027 " %% ends low level\n"))
1029 ((stringp org-export-latex-low-levels)
1030 (insert (format org-export-latex-low-levels heading) "\n")
1031 (when label (insert (format "\\label{%s}\n" label)))
1032 (insert (org-export-latex-content content))
1033 (cond ((stringp subcontent) (insert subcontent))
1034 ((listp subcontent) (org-export-latex-sub subcontent)))))))))
1036 ;;; Exporting internals:
1037 (defun org-export-latex-set-initial-vars (ext-plist level)
1038 "Store org local variables required for LaTeX export.
1039 EXT-PLIST is an optional additional plist.
1040 LEVEL indicates the default depth for export."
1041 (setq org-export-latex-todo-keywords-1 org-todo-keywords-1
1042 org-export-latex-done-keywords org-done-keywords
1043 org-export-latex-not-done-keywords org-not-done-keywords
1044 org-export-latex-complex-heading-re org-complex-heading-regexp
1045 org-export-latex-display-custom-times org-display-custom-times
1046 org-export-latex-all-targets-re
1047 (org-make-target-link-regexp (org-all-targets))
1048 org-export-latex-options-plist
1049 (org-combine-plists (org-default-export-plist) ext-plist
1050 (org-infile-export-plist))
1051 org-export-latex-class
1052 (or (and (org-region-active-p)
1053 (save-excursion
1054 (goto-char (region-beginning))
1055 (and (looking-at org-complex-heading-regexp)
1056 (org-entry-get nil "LaTeX_CLASS" 'selective))))
1057 (save-excursion
1058 (save-restriction
1059 (widen)
1060 (goto-char (point-min))
1061 (and (re-search-forward "^#\\+LaTeX_CLASS:[ \t]*\\([a-zA-Z]+\\)" nil t)
1062 (match-string 1))))
1063 (plist-get org-export-latex-options-plist :latex-class)
1064 org-export-latex-default-class)
1065 org-export-latex-class-options
1066 (or (and (org-region-active-p)
1067 (save-excursion
1068 (goto-char (region-beginning))
1069 (and (looking-at org-complex-heading-regexp)
1070 (org-entry-get nil "LaTeX_CLASS_OPTIONS" 'selective))))
1071 (save-excursion
1072 (save-restriction
1073 (widen)
1074 (goto-char (point-min))
1075 (and (re-search-forward "^#\\+LaTeX_CLASS_OPTIONS:[ \t]*\\(.*?\\)[ \t]*$" nil t)
1076 (match-string 1))))
1077 (plist-get org-export-latex-options-plist :latex-class-options))
1078 org-export-latex-class
1079 (or (car (assoc org-export-latex-class org-export-latex-classes))
1080 (error "No definition for class `%s' in `org-export-latex-classes'"
1081 org-export-latex-class))
1082 org-export-latex-header
1083 (cadr (assoc org-export-latex-class org-export-latex-classes))
1084 org-export-latex-sectioning
1085 (cddr (assoc org-export-latex-class org-export-latex-classes))
1086 org-export-latex-sectioning-depth
1087 (or level
1088 (let ((hl-levels
1089 (plist-get org-export-latex-options-plist :headline-levels))
1090 (sec-depth (length org-export-latex-sectioning)))
1091 (if (> hl-levels sec-depth) sec-depth hl-levels))))
1092 (when (and org-export-latex-class-options
1093 (string-match "\\S-" org-export-latex-class-options)
1094 (string-match "^[ \t]*\\(\\\\documentclass\\)\\(\\[.*?\\]\\)?"
1095 org-export-latex-header))
1096 (setq org-export-latex-header
1097 (concat (substring org-export-latex-header 0 (match-end 1))
1098 org-export-latex-class-options
1099 (substring org-export-latex-header (match-end 0))))))
1101 (defvar org-export-latex-format-toc-function
1102 'org-export-latex-format-toc-default
1103 "The function formatting returning the string to createthe table of contents.
1104 The function mus take one parameter, the depth of the table of contents.")
1106 (defun org-export-latex-make-header (title opt-plist)
1107 "Make the LaTeX header and return it as a string.
1108 TITLE is the current title from the buffer or region.
1109 OPT-PLIST is the options plist for current buffer."
1110 (let ((toc (plist-get opt-plist :table-of-contents))
1111 (author (org-export-apply-macros-in-string
1112 (plist-get opt-plist :author))))
1113 (concat
1114 (if (plist-get opt-plist :time-stamp-file)
1115 (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
1116 ;; insert LaTeX custom header
1117 (org-export-apply-macros-in-string org-export-latex-header)
1118 "\n"
1119 ;; insert information on LaTeX packages
1120 (when (or org-export-latex-default-packages-alist
1121 org-export-latex-packages-alist)
1122 (concat
1123 (mapconcat (lambda(p)
1124 (if (equal "" (car p))
1125 (format "\\usepackage{%s}" (cadr p))
1126 (format "\\usepackage[%s]{%s}"
1127 (car p) (cadr p))))
1128 (append org-export-latex-default-packages-alist
1129 org-export-latex-packages-alist)
1130 "\n")
1131 "\n"))
1132 ;; insert additional commands in the header
1133 (org-export-apply-macros-in-string
1134 (plist-get opt-plist :latex-header-extra))
1135 (org-export-apply-macros-in-string org-export-latex-append-header)
1136 ;; define align if not yet defined
1137 "\\providecommand{\\alert}[1]{\\textbf{#1}}"
1138 ;; insert the title
1139 (format
1140 "\n\n\\title{%s}\n"
1141 ;; convert the title
1142 (org-export-latex-content
1143 title '(lists tables fixed-width keywords)))
1144 ;; insert author info
1145 (if (plist-get opt-plist :author-info)
1146 (format "\\author{%s}\n"
1147 (org-export-latex-fontify-headline (or author user-full-name)))
1148 (format "%%\\author{%s}\n"
1149 (org-export-latex-fontify-headline (or author user-full-name))))
1150 ;; insert the date
1151 (format "\\date{%s}\n"
1152 (format-time-string
1153 (or (plist-get opt-plist :date)
1154 org-export-latex-date-format)))
1155 ;; beginning of the document
1156 "\n\\begin{document}\n\n"
1157 ;; insert the title command
1158 (when (string-match "\\S-" title)
1159 (if (string-match "%s" org-export-latex-title-command)
1160 (format org-export-latex-title-command title)
1161 org-export-latex-title-command))
1162 "\n\n"
1163 ;; table of contents
1164 (when (and org-export-with-toc
1165 (plist-get opt-plist :section-numbers))
1166 (funcall org-export-latex-format-toc-function
1167 (cond ((numberp toc)
1168 (min toc (plist-get opt-plist :headline-levels)))
1169 (toc (plist-get opt-plist :headline-levels))))))))
1171 (defun org-export-latex-format-toc-default (depth)
1172 (when depth
1173 (format "\\setcounter{tocdepth}{%s}\n\\tableofcontents\n\\vspace*{1cm}\n"
1174 depth)))
1176 (defun org-export-latex-first-lines (opt-plist &optional beg end)
1177 "Export the first lines before first headline.
1178 If BEG is non-nil, it is the beginning of the region.
1179 If END is non-nil, it is the end of the region."
1180 (save-excursion
1181 (goto-char (or beg (point-min)))
1182 (let* ((pt (point))
1183 (end (if (re-search-forward "^\\*+ " end t)
1184 (goto-char (match-beginning 0))
1185 (goto-char (or end (point-max))))))
1186 (prog1
1187 (org-export-latex-content
1188 (org-export-preprocess-string
1189 (buffer-substring pt end)
1190 :for-LaTeX t
1191 :emph-multiline t
1192 :add-text nil
1193 :comments nil
1194 :skip-before-1st-heading nil
1195 :LaTeX-fragments nil
1196 :timestamps (plist-get opt-plist :timestamps)
1197 :footnotes (plist-get opt-plist :footnotes)))
1198 (org-unmodified
1199 (let ((inhibit-read-only t))
1200 (add-text-properties pt (max pt (1- end))
1201 '(:org-license-to-kill t))))))))
1203 (defvar org-export-latex-header-defs nil
1204 "The header definitions that might be used in the LaTeX body.")
1205 (defvar org-export-latex-header-defs-re nil
1206 "The header definitions that might be used in the LaTeX body.")
1208 (defun org-export-latex-content (content &optional exclude-list)
1209 "Convert CONTENT string to LaTeX.
1210 Don't perform conversions that are in EXCLUDE-LIST. Recognized
1211 conversion types are: quotation-marks, emphasis, sub-superscript,
1212 links, keywords, lists, tables, fixed-width"
1213 (with-temp-buffer
1214 (insert content)
1215 (unless (memq 'timestamps exclude-list)
1216 (org-export-latex-time-stamps))
1217 (unless (memq 'quotation-marks exclude-list)
1218 (org-export-latex-quotation-marks))
1219 (unless (memq 'emphasis exclude-list)
1220 (when (plist-get org-export-latex-options-plist :emphasize)
1221 (org-export-latex-fontify)))
1222 (unless (memq 'sub-superscript exclude-list)
1223 (org-export-latex-special-chars
1224 (plist-get org-export-latex-options-plist :sub-superscript)))
1225 (unless (memq 'links exclude-list)
1226 (org-export-latex-links))
1227 (unless (memq 'keywords exclude-list)
1228 (org-export-latex-keywords))
1229 (unless (memq 'lists exclude-list)
1230 (org-export-latex-lists))
1231 (unless (memq 'tables exclude-list)
1232 (org-export-latex-tables
1233 (plist-get org-export-latex-options-plist :tables)))
1234 (unless (memq 'fixed-width exclude-list)
1235 (org-export-latex-fixed-width
1236 (plist-get org-export-latex-options-plist :fixed-width)))
1237 ;; return string
1238 (buffer-substring (point-min) (point-max))))
1240 (defun org-export-latex-protect-string (s)
1241 "Add the org-protected property to string S."
1242 (add-text-properties 0 (length s) '(org-protected t) s) s)
1244 (defun org-export-latex-protect-char-in-string (char-list string)
1245 "Add org-protected text-property to char from CHAR-LIST in STRING."
1246 (with-temp-buffer
1247 (save-match-data
1248 (insert string)
1249 (goto-char (point-min))
1250 (while (re-search-forward (regexp-opt char-list) nil t)
1251 (add-text-properties (match-beginning 0)
1252 (match-end 0) '(org-protected t)))
1253 (buffer-string))))
1255 (defun org-export-latex-keywords-maybe (&optional remove-list)
1256 "Maybe remove keywords depending on rules in REMOVE-LIST."
1257 (goto-char (point-min))
1258 (let ((re-todo (mapconcat 'identity org-export-latex-todo-keywords-1 "\\|"))
1259 (case-fold-search nil)
1260 (todo-markup org-export-latex-todo-keyword-markup)
1261 fmt)
1262 ;; convert TODO keywords
1263 (when (re-search-forward (concat "^\\(" re-todo "\\)") nil t)
1264 (if (plist-get remove-list :todo)
1265 (replace-match "")
1266 (setq fmt (cond
1267 ((stringp todo-markup) todo-markup)
1268 ((and (consp todo-markup) (stringp (car todo-markup)))
1269 (if (member (match-string 1) org-export-latex-done-keywords)
1270 (cdr todo-markup) (car todo-markup)))
1271 (t (cdr (or (assoc (match-string 1) todo-markup)
1272 (car todo-markup))))))
1273 (replace-match (format fmt (match-string 1)) t t)))
1274 ;; convert priority string
1275 (when (re-search-forward "\\[\\\\#.\\]" nil t)
1276 (if (plist-get remove-list :priority)
1277 (replace-match "")
1278 (replace-match (format "\\textbf{%s}" (match-string 0)) t t)))
1279 ;; convert tags
1280 (when (re-search-forward "\\(:[a-zA-Z0-9_@]+\\)+:" nil t)
1281 (if (or (not org-export-with-tags)
1282 (plist-get remove-list :tags))
1283 (replace-match "")
1284 (replace-match
1285 (org-export-latex-protect-string
1286 (format "\\textbf{%s}"
1287 (save-match-data
1288 (replace-regexp-in-string
1289 "_" "\\\\_" (match-string 0)))))
1290 t t)))))
1292 (defun org-export-latex-fontify-headline (string)
1293 "Fontify special words in STRING."
1294 (with-temp-buffer
1295 ;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at
1296 ;; the beginning of the buffer - inserting "\n" is safe here though.
1297 (insert "\n" string)
1298 (goto-char (point-min))
1299 (let ((re (concat "\\\\[a-zA-Z]+"
1300 "\\(?:<[^<>\n]*>\\)*"
1301 "\\(?:\\[[^][\n]*?\\]\\)*"
1302 "\\(?:<[^<>\n]*>\\)*"
1303 "\\("
1304 (org-create-multibrace-regexp "{" "}" 3)
1305 "\\)\\{1,3\\}")))
1306 (while (re-search-forward re nil t)
1307 (unless (save-excursion (goto-char (match-beginning 0))
1308 (equal (char-after (point-at-bol)) ?#))
1309 (add-text-properties (match-beginning 0) (match-end 0)
1310 '(org-protected t)))))
1311 (when (plist-get org-export-latex-options-plist :emphasize)
1312 (org-export-latex-fontify))
1313 (org-export-latex-keywords-maybe)
1314 (org-export-latex-special-chars
1315 (plist-get org-export-latex-options-plist :sub-superscript))
1316 (org-export-latex-links)
1317 (org-trim (buffer-string))))
1319 (defun org-export-latex-time-stamps ()
1320 "Format time stamps."
1321 (goto-char (point-min))
1322 (let ((org-display-custom-times org-export-latex-display-custom-times))
1323 (while (re-search-forward org-ts-regexp-both nil t)
1324 (org-if-unprotected-at (1- (point))
1325 (replace-match
1326 (org-export-latex-protect-string
1327 (format org-export-latex-timestamp-markup
1328 (substring (org-translate-time (match-string 0)) 1 -1)))
1329 t t)))))
1331 (defun org-export-latex-quotation-marks ()
1332 "Export quotation marks depending on language conventions."
1333 (let* ((lang (plist-get org-export-latex-options-plist :language))
1334 (quote-rpl (if (equal lang "fr")
1335 '(("\\(\\s-\\)\"" "«~")
1336 ("\\(\\S-\\)\"" "~»")
1337 ("\\(\\s-\\)'" "`"))
1338 '(("\\(\\s-\\|[[(]\\)\"" "``")
1339 ("\\(\\S-\\)\"" "''")
1340 ("\\(\\s-\\|(\\)'" "`")))))
1341 (mapc (lambda(l) (goto-char (point-min))
1342 (while (re-search-forward (car l) nil t)
1343 (let ((rpl (concat (match-string 1)
1344 (org-export-latex-protect-string
1345 (copy-sequence (cadr l))))))
1346 (org-if-unprotected-1
1347 (replace-match rpl t t))))) quote-rpl)))
1349 (defun org-export-latex-special-chars (sub-superscript)
1350 "Export special characters to LaTeX.
1351 If SUB-SUPERSCRIPT is non-nil, convert \\ and ^.
1352 See the `org-export-latex.el' code for a complete conversion table."
1353 (goto-char (point-min))
1354 (mapc (lambda(c)
1355 (goto-char (point-min))
1356 (while (re-search-forward c nil t)
1357 ;; Put the point where to check for org-protected
1358 (unless (get-text-property (match-beginning 2) 'org-protected)
1359 (cond ((member (match-string 2) '("\\$" "$"))
1360 (if (equal (match-string 2) "\\$")
1362 (replace-match "\\$" t t)))
1363 ((member (match-string 2) '("&" "%" "#"))
1364 (if (equal (match-string 1) "\\")
1365 (replace-match (match-string 2) t t)
1366 (replace-match (concat (match-string 1) "\\"
1367 (match-string 2)) t t)
1368 (backward-char 1)))
1369 ((equal (match-string 2) "...")
1370 (replace-match
1371 (concat (match-string 1)
1372 (org-export-latex-protect-string "\\ldots{}")) t t))
1373 ((equal (match-string 2) "~")
1374 (cond ((equal (match-string 1) "\\") nil)
1375 ((eq 'org-link (get-text-property 0 'face (match-string 2)))
1376 (replace-match (concat (match-string 1) "\\~") t t))
1377 (t (replace-match
1378 (org-export-latex-protect-string
1379 (concat (match-string 1) "\\~{}")) t t))))
1380 ((member (match-string 2) '("{" "}"))
1381 (unless (save-match-data (org-inside-latex-math-p))
1382 (if (equal (match-string 1) "\\")
1383 (replace-match (match-string 2) t t)
1384 (replace-match (concat (match-string 1) "\\"
1385 (match-string 2)) t t)))))
1386 (unless (save-match-data (org-inside-latex-math-p))
1387 (cond ((equal (match-string 2) "\\")
1388 (replace-match (or (save-match-data
1389 (org-export-latex-treat-backslash-char
1390 (match-string 1)
1391 (or (match-string 3) "")))
1392 "") t t)
1393 (backward-char 1))
1394 ((member (match-string 2) '("_" "^"))
1395 (replace-match (or (save-match-data
1396 (org-export-latex-treat-sub-super-char
1397 sub-superscript
1398 (match-string 2)
1399 (match-string 1)
1400 (match-string 3))) "") t t)
1401 (backward-char 1)))))))
1402 '(;"^\\([^\n$]*?\\|^\\)\\(\\\\?\\$\\)\\([^\n$]*\\)$"
1403 "\\(\\(\\\\?\\$\\)\\)"
1404 "\\([a-zA-Z0-9()]+\\|[ \t\n]\\|\\b\\|\\\\\\)\\(_\\|\\^\\)\\({[^{}]+}\\|[a-zA-Z0-9]+\\|[ \t\n]\\|[:punct:]\\|)\\|{[a-zA-Z0-9]+}\\|([a-zA-Z0-9]+)\\)"
1405 "\\(.\\|^\\)\\(\\\\\\)\\([ \t\n]\\|\\([&#%{}\"]\\|[a-zA-Z][a-zA-Z0-9]*\\)\\)"
1406 "\\(.\\|^\\)\\(&\\)"
1407 "\\(.\\|^\\)\\(#\\)"
1408 "\\(.\\|^\\)\\(%\\)"
1409 "\\(.\\|^\\)\\({\\)"
1410 "\\(.\\|^\\)\\(}\\)"
1411 "\\(.\\|^\\)\\(~\\)"
1412 "\\(.\\|^\\)\\(\\.\\.\\.\\)"
1413 ;; (?\< . "\\textless{}")
1414 ;; (?\> . "\\textgreater{}")
1417 (defun org-inside-latex-math-p ()
1418 (get-text-property (point) 'org-latex-math))
1420 (defun org-export-latex-treat-sub-super-char
1421 (subsup char string-before string-after)
1422 "Convert the \"_\" and \"^\" characters to LaTeX.
1423 SUBSUP corresponds to the ^: option in the #+OPTIONS line.
1424 Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
1425 (cond ((equal string-before "\\")
1426 (concat string-before char string-after))
1427 ((and (string-match "\\S-+" string-after))
1428 ;; this is part of a math formula
1429 (cond ((eq 'org-link (get-text-property 0 'face char))
1430 (concat string-before "\\" char string-after))
1431 ((save-match-data (org-inside-latex-math-p))
1432 (if subsup
1433 (cond ((eq 1 (length string-after))
1434 (concat string-before char string-after))
1435 ((string-match "[({]?\\([^)}]+\\)[)}]?" string-after)
1436 (format "%s%s{%s}" string-before char
1437 (match-string 1 string-after))))))
1438 ((and (> (length string-after) 1)
1439 (or (eq subsup t)
1440 (and (equal subsup '{}) (eq (string-to-char string-after) ?\{)))
1441 (string-match "[({]?\\([^)}]+\\)[)}]?" string-after))
1442 (org-export-latex-protect-string
1443 (format "%s$%s{%s}$" string-before char
1444 (if (and (> (match-end 1) (1+ (match-beginning 1)))
1445 (not (equal (substring string-after 0 2) "{\\")))
1446 (concat "\\mathrm{" (match-string 1 string-after) "}")
1447 (match-string 1 string-after)))))
1448 ((eq subsup t) (concat string-before "$" char string-after "$"))
1449 (t (org-export-latex-protect-string
1450 (concat string-before "\\" char "{}" string-after)))))
1451 (t (org-export-latex-protect-string
1452 (concat string-before "\\" char "{}" string-after)))))
1454 (defun org-export-latex-treat-backslash-char (string-before string-after)
1455 "Convert the \"$\" special character to LaTeX.
1456 The conversion is made depending of STRING-BEFORE and STRING-AFTER."
1457 (let ((ass (org-entity-get string-after)))
1458 (cond
1459 (ass (if (nth 2 ass)
1460 (concat string-before
1461 (org-export-latex-protect-string
1462 (concat "$" (nth 1 ass) "$")))
1463 (concat string-before (org-export-latex-protect-string
1464 (nth 1 ass)))))
1465 ((and (not (string-match "^[ \n\t]" string-after))
1466 (not (string-match "[ \t]\\'\\|^" string-before)))
1467 ;; backslash is inside a word
1468 (concat string-before
1469 (org-export-latex-protect-string
1470 (concat "\\textbackslash{}" string-after))))
1471 ((not (or (equal string-after "")
1472 (string-match "^[ \t\n]" string-after)))
1473 ;; backslash might escape a character (like \#) or a user TeX
1474 ;; macro (like \setcounter)
1475 (concat string-before
1476 (org-export-latex-protect-string (concat "\\" string-after))))
1477 ((and (string-match "^[ \t\n]" string-after)
1478 (string-match "[ \t\n]\\'" string-before))
1479 ;; backslash is alone, convert it to $\backslash$
1480 (org-export-latex-protect-string
1481 (concat string-before "\\textbackslash{}" string-after)))
1482 (t (org-export-latex-protect-string
1483 (concat string-before "\\textbackslash{}" string-after))))))
1485 (defun org-export-latex-keywords ()
1486 "Convert special keywords to LaTeX."
1487 (goto-char (point-min))
1488 (while (re-search-forward org-export-latex-special-keyword-regexp nil t)
1489 (replace-match (format org-export-latex-timestamp-keyword-markup
1490 (match-string 0)) t t)
1491 (save-excursion
1492 (beginning-of-line 1)
1493 (unless (looking-at ".*\n[ \t]*\n")
1494 (end-of-line 1)
1495 (insert "\n")))))
1497 (defun org-export-latex-fixed-width (opt)
1498 "When OPT is non-nil convert fixed-width sections to LaTeX."
1499 (goto-char (point-min))
1500 (while (re-search-forward "^[ \t]*:\\([ \t]\\|$\\)" nil t)
1501 (if opt
1502 (progn (goto-char (match-beginning 0))
1503 (insert "\\begin{verbatim}\n")
1504 (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
1505 (replace-match (concat (match-string 1)
1506 (match-string 2)) t t)
1507 (forward-line))
1508 (insert "\\end{verbatim}\n\n"))
1509 (progn (goto-char (match-beginning 0))
1510 (while (looking-at "^\\([ \t]*\\):\\(\\([ \t]\\|$\\).*\\)$")
1511 (replace-match (concat "%" (match-string 1)
1512 (match-string 2)) t t)
1513 (forward-line))))))
1516 (defvar org-table-last-alignment) ; defined in org-table.el
1517 (defvar org-table-last-column-widths) ; defined in org-table.el
1518 (declare-function orgtbl-to-latex "org-table" (table params) t)
1519 (defun org-export-latex-tables (insert)
1520 "Convert tables to LaTeX and INSERT it."
1521 ;; First, get the table.el tables
1522 (goto-char (point-min))
1523 (while (re-search-forward "^[ \t]*\\(\\+-[-+]*\\+\\)[ \t]*\n[ \t]*|" nil t)
1524 (org-if-unprotected
1525 (require 'table)
1526 (org-export-latex-convert-table.el-table)))
1528 ;; And now the Org-mode tables
1529 (goto-char (point-min))
1530 (while (re-search-forward "^\\([ \t]*\\)|" nil t)
1531 (org-if-unprotected-at (1- (point))
1532 (org-table-align)
1533 (let* ((beg (org-table-begin))
1534 (end (org-table-end))
1535 (raw-table (buffer-substring beg end))
1536 (org-table-last-alignment (copy-sequence org-table-last-alignment))
1537 (org-table-last-column-widths (copy-sequence
1538 org-table-last-column-widths))
1539 fnum fields line lines olines gr colgropen line-fmt align
1540 caption label attr floatp longtblp)
1541 (if org-export-latex-tables-verbatim
1542 (let* ((tbl (concat "\\begin{verbatim}\n" raw-table
1543 "\\end{verbatim}\n")))
1544 (apply 'delete-region (list beg end))
1545 (insert (org-export-latex-protect-string tbl)))
1546 (progn
1547 (setq caption (org-find-text-property-in-string
1548 'org-caption raw-table)
1549 attr (org-find-text-property-in-string
1550 'org-attributes raw-table)
1551 label (org-find-text-property-in-string
1552 'org-label raw-table)
1553 longtblp (and attr (stringp attr)
1554 (string-match "\\<longtable\\>" attr))
1555 align (and attr (stringp attr)
1556 (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
1557 (match-string 1 attr))
1558 floatp (or caption label))
1559 (setq caption (and caption (org-export-latex-content caption)))
1560 (setq lines (org-split-string raw-table "\n"))
1561 (apply 'delete-region (list beg end))
1562 (when org-export-table-remove-special-lines
1563 (setq lines (org-table-clean-before-export lines 'maybe-quoted)))
1564 (when org-table-clean-did-remove-column
1565 (pop org-table-last-alignment)
1566 (pop org-table-last-column-widths))
1567 ;; make a formatting string to reflect alignment
1568 (setq olines lines)
1569 (while (and (not line-fmt) (setq line (pop olines)))
1570 (unless (string-match "^[ \t]*|-" line)
1571 (setq fields (org-split-string line "[ \t]*|[ \t]*"))
1572 (setq fnum (make-vector (length fields) 0))
1573 (setq line-fmt
1574 (mapconcat
1575 (lambda (x)
1576 (setq gr (pop org-table-colgroup-info))
1577 (format "%s%%s%s"
1578 (cond ((eq gr :start)
1579 (prog1 (if colgropen "|" "|")
1580 (setq colgropen t)))
1581 ((eq gr :startend)
1582 (prog1 (if colgropen "|" "|")
1583 (setq colgropen nil)))
1584 (t ""))
1585 (if (memq gr '(:end :startend))
1586 (progn (setq colgropen nil) "|")
1587 "")))
1588 fnum ""))))
1589 ;; fix double || in line-fmt
1590 (setq line-fmt (replace-regexp-in-string "||" "|" line-fmt))
1591 ;; maybe remove the first and last "|"
1592 (when (and (not org-export-latex-tables-column-borders)
1593 (string-match "^\\(|\\)?\\(.+\\)|$" line-fmt))
1594 (setq line-fmt (match-string 2 line-fmt)))
1595 ;; format alignment
1596 (unless align
1597 (setq align (apply 'format
1598 (cons line-fmt
1599 (mapcar (lambda (x) (if x "r" "l"))
1600 org-table-last-alignment)))))
1601 ;; prepare the table to send to orgtbl-to-latex
1602 (setq lines
1603 (mapcar
1604 (lambda(elem)
1605 (or (and (string-match "[ \t]*|-+" elem) 'hline)
1606 (org-split-string (org-trim elem) "|")))
1607 lines))
1608 (when insert
1609 (insert (org-export-latex-protect-string
1610 (concat
1611 (if longtblp
1612 (concat "\\begin{longtable}{" align "}\n")
1613 (if floatp "\\begin{table}[htb]\n"))
1614 (if floatp
1615 (format
1616 "\\caption{%s%s}"
1617 (if label (concat "\\\label{" label "}") "")
1618 (or caption "")))
1619 (if (and longtblp caption) "\\\\\n" "\n")
1620 (if (and org-export-latex-tables-centered (not longtblp))
1621 "\\begin{center}\n")
1622 (if (not longtblp) (concat "\\begin{tabular}{" align "}\n"))
1623 (orgtbl-to-latex
1624 lines
1625 `(:tstart nil :tend nil
1626 :hlend ,(if longtblp
1627 (format "\\\\
1628 \\hline
1629 \\endhead
1630 \\hline\\multicolumn{%d}{r}{Continued on next page}\\
1631 \\endfoot
1632 \\endlastfoot" (length org-table-last-alignment))
1633 nil)))
1634 (if (not longtblp) (concat "\n\\end{tabular}"))
1635 (if longtblp "\n" (if org-export-latex-tables-centered
1636 "\n\\end{center}\n" "\n"))
1637 (if longtblp
1638 "\\end{longtable}"
1639 (if floatp "\\end{table}"))))
1640 "\n\n"))))))))
1642 (defun org-export-latex-convert-table.el-table ()
1643 "Replace table.el table at point with LaTeX code."
1644 (let (tbl caption label line floatp attr align rmlines)
1645 (setq line (buffer-substring (point-at-bol) (point-at-eol))
1646 label (org-get-text-property-any 0 'org-label line)
1647 caption (org-get-text-property-any 0 'org-caption line)
1648 attr (org-get-text-property-any 0 'org-attributes line)
1649 align (and attr (stringp attr)
1650 (string-match "\\<align=\\([^ \t\n\r,]+\\)" attr)
1651 (match-string 1 attr))
1652 rmlines (and attr (stringp attr)
1653 (string-match "\\<rmlines\\>" attr))
1654 floatp (or label caption))
1655 (and (get-buffer "*org-export-table*")
1656 (kill-buffer (get-buffer "*org-export-table*")))
1657 (table-generate-source 'latex "*org-export-table*" "caption")
1658 (setq tbl (with-current-buffer "*org-export-table*"
1659 (buffer-string)))
1660 (while (string-match "^%.*\n" tbl)
1661 (setq tbl (replace-match "" t t tbl)))
1662 ;; fix the hlines
1663 (when rmlines
1664 (let ((n 0) lines)
1665 (setq lines (mapcar (lambda (x)
1666 (if (string-match "^\\\\hline$" x)
1667 (progn
1668 (setq n (1+ n))
1669 (if (= n 2) x nil))
1671 (org-split-string tbl "\n")))
1672 (setq tbl (mapconcat 'identity (delq nil lines) "\n"))))
1673 (when (and align (string-match "\\\\begin{tabular}{.*}" tbl))
1674 (setq tbl (replace-match (concat "\\begin{tabular}{" align "}")
1675 t t tbl)))
1676 (and (get-buffer "*org-export-table*")
1677 (kill-buffer (get-buffer "*org-export-table*")))
1678 (beginning-of-line 0)
1679 (while (looking-at "[ \t]*\\(|\\|\\+-\\)")
1680 (delete-region (point) (1+ (point-at-eol))))
1681 (when org-export-latex-tables-centered
1682 (setq tbl (concat "\\begin{center}\n" tbl "\\end{center}")))
1683 (when floatp
1684 (setq tbl (concat "\\begin{table}\n"
1685 (format "\\caption{%s%s}\n"
1686 (if label (format "\\label{%s}" label) "")
1687 (or caption ""))
1689 "\n\\end{table}\n")))
1690 (insert (org-export-latex-protect-string tbl))))
1692 (defun org-export-latex-fontify ()
1693 "Convert fontification to LaTeX."
1694 (goto-char (point-min))
1695 (while (re-search-forward org-emph-re nil t)
1696 ;; The match goes one char after the *string*, except at the end of a line
1697 (let ((emph (assoc (match-string 3)
1698 org-export-latex-emphasis-alist))
1699 (beg (match-beginning 0))
1700 (end (match-end 0))
1701 rpl s)
1702 (unless emph
1703 (message "`org-export-latex-emphasis-alist' has no entry for formatting triggered by \"%s\""
1704 (match-string 3)))
1705 (unless (or (and (get-text-property (- (point) 2) 'org-protected)
1706 (not (get-text-property
1707 (- (point) 2) 'org-verbatim-emph)))
1708 (save-excursion
1709 (goto-char (match-beginning 1))
1710 (save-match-data
1711 (and (org-at-table-p)
1712 (string-match
1713 "[|\n]" (buffer-substring beg end)))))
1714 (and (equal (match-string 3) "+")
1715 (save-match-data
1716 (string-match "\\`-+\\'" (match-string 4)))))
1717 (setq s (match-string 4))
1718 (setq rpl (concat (match-string 1)
1719 (org-export-latex-emph-format (cadr emph)
1720 (match-string 4))
1721 (match-string 5)))
1722 (if (caddr emph)
1723 (setq rpl (org-export-latex-protect-string rpl))
1724 (save-match-data
1725 (if (string-match "\\`.?\\(\\\\[a-z]+{\\)\\(.*\\)\\(}\\).?\\'" rpl)
1726 (progn
1727 (add-text-properties (match-beginning 1) (match-end 1)
1728 '(org-protected t) rpl)
1729 (add-text-properties (match-beginning 3) (match-end 3)
1730 '(org-protected t) rpl)))))
1731 (replace-match rpl t t)))
1732 (backward-char)))
1734 (defvar org-export-latex-use-verb nil)
1735 (defun org-export-latex-emph-format (format string)
1736 "Format an emphasis string and handle the \\verb special case."
1737 (when (equal format "\\verb")
1738 (save-match-data
1739 (if org-export-latex-use-verb
1740 (let ((ll "~,./?;':\"|!@#%^&-_=+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>()[]{}"))
1741 (catch 'exit
1742 (loop for i from 0 to (1- (length ll)) do
1743 (if (not (string-match (regexp-quote (substring ll i (1+ i)))
1744 string))
1745 (progn
1746 (setq format (concat "\\verb" (substring ll i (1+ i))
1747 "%s" (substring ll i (1+ i))))
1748 (throw 'exit nil))))))
1749 (let ((start 0)
1750 (trans '(("\\" . "\\textbackslash{}")
1751 ("~" . "\\textasciitilde{}")
1752 ("^" . "\\textasciicircum{}")))
1753 (rtn "") char)
1754 (while (string-match "[\\{}$%&_#~^]" string)
1755 (setq char (match-string 0 string))
1756 (if (> (match-beginning 0) 0)
1757 (setq rtn (concat rtn (substring string
1758 0 (match-beginning 0)))))
1759 (setq string (substring string (1+ (match-beginning 0))))
1760 (setq char (or (cdr (assoc char trans)) (concat "\\" char))
1761 rtn (concat rtn char)))
1762 (setq string (concat rtn string) format "\\texttt{%s}")))))
1763 (format format string))
1765 (defun org-export-latex-links ()
1766 ;; Make sure to use the LaTeX hyperref and graphicx package
1767 ;; or send some warnings.
1768 "Convert links to LaTeX."
1769 (goto-char (point-min))
1770 (while (re-search-forward org-bracket-link-analytic-regexp++ nil t)
1771 (org-if-unprotected-1
1772 (goto-char (match-beginning 0))
1773 (let* ((re-radio org-export-latex-all-targets-re)
1774 (remove (list (match-beginning 0) (match-end 0)))
1775 (raw-path (org-extract-attributes (match-string 3)))
1776 (full-raw-path (concat (match-string 1) raw-path))
1777 (desc (match-string 5))
1778 (type (or (match-string 2)
1779 (if (or (file-name-absolute-p raw-path)
1780 (string-match "^\\.\\.?/" raw-path))
1781 "file")))
1782 (coderefp (equal type "coderef"))
1783 (caption (org-find-text-property-in-string 'org-caption raw-path))
1784 (attr (or (org-find-text-property-in-string 'org-attributes raw-path)
1785 (plist-get org-export-latex-options-plist :latex-image-options)))
1786 (label (org-find-text-property-in-string 'org-label raw-path))
1787 imgp radiop
1788 ;; define the path of the link
1789 (path (cond
1790 ((member type '("coderef"))
1791 raw-path)
1792 ((member type '("http" "https" "ftp"))
1793 (concat type ":" raw-path))
1794 ((and re-radio (string-match re-radio raw-path))
1795 (setq radiop t))
1796 ((equal type "mailto")
1797 (concat type ":" raw-path))
1798 ((equal type "file")
1799 (if (and (org-file-image-p
1800 (expand-file-name
1801 raw-path)
1802 org-export-latex-inline-image-extensions)
1803 (or (get-text-property 0 'org-no-description
1804 raw-path)
1805 (equal desc full-raw-path)))
1806 (setq imgp t)
1807 (progn (when (string-match "\\(.+\\)::.+" raw-path)
1808 (setq raw-path (match-string 1 raw-path)))
1809 (if (file-exists-p raw-path)
1810 (concat type "://" (expand-file-name raw-path))
1811 (concat type "://" (org-export-directory
1812 :LaTeX org-export-latex-options-plist)
1813 raw-path))))))))
1814 ;; process with link inserting
1815 (apply 'delete-region remove)
1816 (setq caption (and caption (org-export-latex-content caption)))
1817 (cond ((and imgp
1818 (plist-get org-export-latex-options-plist :inline-images))
1819 ;; OK, we need to inline an image
1820 (insert
1821 (org-export-latex-format-image raw-path caption label attr)))
1822 (coderefp
1823 (insert (format
1824 (org-export-get-coderef-format path desc)
1825 (cdr (assoc path org-export-code-refs)))))
1826 (radiop (insert (format "\\hyperref[%s]{%s}"
1827 (org-solidify-link-text raw-path) desc)))
1828 ((not type)
1829 (insert (format "\\hyperref[%s]{%s}"
1830 (org-remove-initial-hash
1831 (org-solidify-link-text raw-path))
1832 desc)))
1833 (path
1834 (when (org-at-table-p)
1835 ;; There is a strange problem when we have a link in a table,
1836 ;; ampersands then cause a problem. I think this must be
1837 ;; a LaTeX issue, but we here implement a work-around anyway.
1838 (setq path (org-export-latex-protect-amp path)
1839 desc (org-export-latex-protect-amp desc)))
1840 (insert (format org-export-latex-hyperref-format path desc)))
1841 (t (insert "\\texttt{" desc "}")))))))
1844 (defun org-export-latex-format-image (path caption label attr)
1845 "Format the image element, depending on user settings."
1846 (let (ind floatp wrapp placement figenv)
1847 (setq floatp (or caption label))
1848 (setq ind (org-get-text-property-any 0 'original-indentation path))
1849 (when (and attr (stringp attr))
1850 (if (string-match "[ \t]*\\<wrap\\>" attr)
1851 (setq wrapp t floatp nil attr (replace-match "" t t attr)))
1852 (if (string-match "[ \t]*\\<float\\>" attr)
1853 (setq wrapp nil floatp t attr (replace-match "" t t attr))))
1855 (setq placement
1856 (cond
1857 (wrapp "{l}{0.5\\textwidth}")
1858 (floatp "[htb]")
1859 (t "")))
1861 (when (and attr (stringp attr)
1862 (string-match "[ \t]*\\<placement=\\(\\S-+\\)" attr))
1863 (setq placement (match-string 1 attr)
1864 attr (replace-match "" t t attr)))
1865 (setq attr (and attr (org-trim attr)))
1866 (when (or (not attr) (= (length attr) 0))
1867 (setq attr (cond (floatp "width=0.7\\textwidth")
1868 (wrapp "width=0.48\\textwidth")
1869 (t attr))))
1870 (setq figenv
1871 (cond
1872 (wrapp "\\begin{wrapfigure}%placement
1873 \\centering
1874 \\includegraphics[%attr]{%path}
1875 \\caption{%labelcmd%caption}
1876 \\end{wrapfigure}")
1877 (floatp "\\begin{figure}%placement
1878 \\centering
1879 \\includegraphics[%attr]{%path}
1880 \\caption{%labelcmd%caption}
1881 \\end{figure}")
1882 (t "\\includegraphics[%attr]{%path}")))
1885 (setq figenv (mapconcat 'identity (split-string figenv "\n")
1886 (save-excursion (beginning-of-line 1)
1887 (looking-at "[ \t]*")
1888 (concat "\n" (match-string 0)))))
1890 (if (and (not label) (not caption)
1891 (string-match "^\\\\caption{.*\n" figenv))
1892 (setq figenv (replace-match "" t t figenv)))
1893 (org-add-props
1894 (org-fill-template
1895 figenv
1896 (list (cons "path"
1897 (if (file-name-absolute-p path)
1898 (expand-file-name path)
1899 path))
1900 (cons "attr" attr)
1901 (cons "labelcmd" (if label (format "\\label{%s}"
1902 label)""))
1903 (cons "caption" (or caption ""))
1904 (cons "placement" (or placement ""))))
1905 nil 'original-indentation ind)))
1907 (defun org-export-latex-protect-amp (s)
1908 (while (string-match "\\([^\\\\]\\)\\(&\\)" s)
1909 (setq s (replace-match (concat (match-string 1 s) "\\" (match-string 2 s))
1910 t t s)))
1913 (defun org-remove-initial-hash (s)
1914 (if (string-match "\\`#" s)
1915 (substring s 1)
1917 (defvar org-latex-entities) ; defined below
1918 (defvar org-latex-entities-regexp) ; defined below
1919 (defvar org-latex-entities-exceptions) ; defined below
1921 (defun org-export-latex-preprocess (parameters)
1922 "Clean stuff in the LaTeX export."
1923 ;; Preserve line breaks
1924 (goto-char (point-min))
1925 (while (re-search-forward "\\\\\\\\" nil t)
1926 (add-text-properties (match-beginning 0) (match-end 0)
1927 '(org-protected t)))
1929 ;; Preserve latex environments
1930 (goto-char (point-min))
1931 (while (re-search-forward "^[ \t]*\\\\begin{\\([a-zA-Z]+\\*?\\)}" nil t)
1932 (let* ((start (progn (beginning-of-line) (point)))
1933 (end (and (re-search-forward
1934 (concat "^[ \t]*\\\\end{"
1935 (regexp-quote (match-string 1))
1936 "}") nil t)
1937 (point-at-eol))))
1938 (if end
1939 (add-text-properties start end '(org-protected t))
1940 (goto-char (point-at-eol)))))
1942 ;; Preserve math snippets
1944 (let* ((matchers (plist-get org-format-latex-options :matchers))
1945 (re-list org-latex-regexps)
1946 beg end re e m n block off)
1947 ;; Check the different regular expressions
1948 (while (setq e (pop re-list))
1949 (setq m (car e) re (nth 1 e) n (nth 2 e)
1950 block (if (nth 3 e) "\n\n" ""))
1951 (setq off (if (member m '("$" "$1")) 1 0))
1952 (when (and (member m matchers) (not (equal m "begin")))
1953 (goto-char (point-min))
1954 (while (re-search-forward re nil t)
1955 (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
1956 (add-text-properties beg end '(org-protected t org-latex-math t))))))
1958 ;; Convert LaTeX to \LaTeX{} and TeX to \TeX{}
1959 (goto-char (point-min))
1960 (let ((case-fold-search nil))
1961 (while (re-search-forward "\\<\\(\\(La\\)?TeX\\)\\>" nil t)
1962 (unless (eq (char-before (match-beginning 1)) ?\\)
1963 (org-if-unprotected-1
1964 (replace-match (org-export-latex-protect-string
1965 (concat "\\" (match-string 1)
1966 "{}")) t t)))))
1968 ;; Convert blockquotes
1969 (goto-char (point-min))
1970 (while (search-forward "ORG-BLOCKQUOTE-START" nil t)
1971 (org-replace-match-keep-properties "\\begin{quote}" t t))
1972 (goto-char (point-min))
1973 (while (search-forward "ORG-BLOCKQUOTE-END" nil t)
1974 (org-replace-match-keep-properties "\\end{quote}" t t))
1976 ;; Convert verse
1977 (goto-char (point-min))
1978 (while (search-forward "ORG-VERSE-START" nil t)
1979 (org-replace-match-keep-properties "\\begin{verse}" t t)
1980 (beginning-of-line 2)
1981 (while (and (not (looking-at "[ \t]*ORG-VERSE-END.*")) (not (eobp)))
1982 (when (looking-at "\\([ \t]+\\)\\([^ \t\n]\\)")
1983 (goto-char (match-end 1))
1984 (org-replace-match-keep-properties
1985 (org-export-latex-protect-string
1986 (concat "\\hspace*{1cm}" (match-string 2))) t t)
1987 (beginning-of-line 1))
1988 (if (looking-at "[ \t]*$")
1989 (insert (org-export-latex-protect-string "\\vspace*{1em}"))
1990 (unless (looking-at ".*?[^ \t\n].*?\\\\\\\\[ \t]*$")
1991 (end-of-line 1)
1992 (insert "\\\\")))
1993 (beginning-of-line 2))
1994 (and (looking-at "[ \t]*ORG-VERSE-END.*")
1995 (org-replace-match-keep-properties "\\end{verse}" t t)))
1997 ;; Convert center
1998 (goto-char (point-min))
1999 (while (search-forward "ORG-CENTER-START" nil t)
2000 (org-replace-match-keep-properties "\\begin{center}" t t))
2001 (goto-char (point-min))
2002 (while (search-forward "ORG-CENTER-END" nil t)
2003 (org-replace-match-keep-properties "\\end{center}" t t))
2005 (run-hooks 'org-export-latex-after-blockquotes-hook)
2007 ;; Convert horizontal rules
2008 (goto-char (point-min))
2009 (while (re-search-forward "^----+.$" nil t)
2010 (org-if-unprotected
2011 (replace-match (org-export-latex-protect-string "\\hrule") t t)))
2013 ;; Protect LaTeX commands like \command[...]{...} or \command{...}
2014 (goto-char (point-min))
2015 (let ((re (concat
2016 "\\\\[a-zA-Z]+"
2017 "\\(?:<[^<>\n]*>\\)*"
2018 "\\(?:\\[[^][\n]*?\\]\\)*"
2019 "\\(?:<[^<>\n]*>\\)*"
2020 "\\(" (org-create-multibrace-regexp "{" "}" 3) "\\)\\{1,3\\}")))
2021 (while (re-search-forward re nil t)
2022 (unless (save-excursion (goto-char (match-beginning 0))
2023 (equal (char-after (point-at-bol)) ?#))
2024 (add-text-properties (match-beginning 0) (match-end 0)
2025 '(org-protected t)))))
2027 ;; Protect LaTeX entities
2028 (goto-char (point-min))
2029 (let (a)
2030 (while (re-search-forward org-latex-entities-regexp nil t)
2031 (if (setq a (assoc (match-string 0) org-latex-entities-exceptions))
2032 (replace-match (org-add-props (nth 1 a) nil 'org-protected t)
2033 t t)
2034 (add-text-properties (match-beginning 0) (match-end 0)
2035 '(org-protected t)))))
2037 ;; Replace radio links
2038 (goto-char (point-min))
2039 (while (re-search-forward
2040 (concat "<<<?" org-export-latex-all-targets-re
2041 ">>>?\\((INVISIBLE)\\)?") nil t)
2042 (org-if-unprotected-at (+ (match-beginning 0) 2)
2043 (replace-match
2044 (concat
2045 (org-export-latex-protect-string
2046 (format "\\label{%s}" (save-match-data (org-solidify-link-text
2047 (match-string 1)))))
2048 (if (match-string 2) "" (match-string 1)))
2049 t t)))
2051 ;; Delete @<...> constructs
2052 ;; Thanks to Daniel Clemente for this regexp
2053 (goto-char (point-min))
2054 (while (re-search-forward "@<\\(?:[^\"\n]\\|\".*\"\\)*?>" nil t)
2055 (org-if-unprotected
2056 (replace-match "")))
2058 ;; When converting to LaTeX, replace footnotes
2059 ;; FIXME: don't protect footnotes from conversion
2060 (when (plist-get org-export-latex-options-plist :footnotes)
2061 (goto-char (point-min))
2062 (while (re-search-forward "\\[\\([0-9]+\\)\\]" nil t)
2063 (org-if-unprotected
2064 (when (and (save-match-data
2065 (save-excursion (beginning-of-line)
2066 (looking-at "[^:|#]")))
2067 (not (org-in-verbatim-emphasis)))
2068 (let ((foot-beg (match-beginning 0))
2069 (foot-end (match-end 0))
2070 (foot-prefix (match-string 0))
2071 footnote footnote-rpl)
2072 (save-excursion
2073 (if (not (re-search-forward (concat "^" (regexp-quote foot-prefix))
2074 nil t))
2075 (replace-match (org-export-latex-protect-string
2076 (concat "$^{" (match-string 1) "}$")))
2077 (replace-match "")
2078 (let ((end (save-excursion
2079 (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t)
2080 (match-beginning 0) (point-max)))))
2081 (setq footnote (concat (org-trim (buffer-substring (point) end))
2082 " ")) ; prevent last } being part of a link
2083 (delete-region (point) end))
2084 (goto-char foot-beg)
2085 (delete-region foot-beg foot-end)
2086 (unless (null footnote)
2087 (setq footnote-rpl (format "\\footnote{%s}" footnote))
2088 (add-text-properties 0 10 '(org-protected t) footnote-rpl)
2089 (add-text-properties (1- (length footnote-rpl))
2090 (length footnote-rpl)
2091 '(org-protected t) footnote-rpl)
2092 (if (org-on-heading-p)
2093 (setq footnote-rpl
2094 (concat (org-export-latex-protect-string "\\protect")
2095 footnote-rpl)))
2096 (insert footnote-rpl)))
2097 )))))
2099 ;; Remove footnote section tag for LaTeX
2100 (goto-char (point-min))
2101 (while (re-search-forward
2102 (concat "^" footnote-section-tag-regexp) nil t)
2103 (org-if-unprotected
2104 (replace-match "")))))
2106 (defun org-export-latex-fix-inputenc ()
2107 "Set the codingsystem in inputenc to what the buffer is."
2108 (let* ((cs buffer-file-coding-system)
2109 (opt (or (ignore-errors (latexenc-coding-system-to-inputenc cs))
2110 "utf8")))
2111 (when opt
2112 ;; Translate if that is requested
2113 (setq opt (or (cdr (assoc opt org-export-latex-inputenc-alist)) opt))
2114 ;; find the \usepackage statement and replace the option
2115 (goto-char (point-min))
2116 (while (re-search-forward "\\\\usepackage\\[\\(AUTO\\)\\]{inputenc}"
2117 nil t)
2118 (goto-char (match-beginning 1))
2119 (delete-region (match-beginning 1) (match-end 1))
2120 (insert opt))
2121 (and buffer-file-name
2122 (save-buffer)))))
2124 ;;; List handling:
2126 (defun org-export-latex-lists ()
2127 "Convert plain text lists in current buffer into LaTeX lists."
2128 (goto-char (point-min))
2129 (while (re-search-forward org-list-beginning-re nil t)
2130 (org-if-unprotected
2131 (beginning-of-line)
2132 (insert (org-list-to-latex (org-list-parse-list t)
2133 org-export-latex-list-parameters))
2134 "\n")))
2136 (defconst org-latex-entities
2137 '("\\!"
2138 "\\'"
2139 "\\+"
2140 "\\,"
2141 "\\-"
2142 "\\:"
2143 "\\;"
2144 "\\<"
2145 "\\="
2146 "\\>"
2147 "\\Huge"
2148 "\\LARGE"
2149 "\\Large"
2150 "\\Styles"
2151 "\\\\"
2152 "\\`"
2153 "\\addcontentsline"
2154 "\\address"
2155 "\\addtocontents"
2156 "\\addtocounter"
2157 "\\addtolength"
2158 "\\addvspace"
2159 "\\alph"
2160 "\\appendix"
2161 "\\arabic"
2162 "\\author"
2163 "\\begin{array}"
2164 "\\begin{center}"
2165 "\\begin{description}"
2166 "\\begin{enumerate}"
2167 "\\begin{eqnarray}"
2168 "\\begin{equation}"
2169 "\\begin{figure}"
2170 "\\begin{flushleft}"
2171 "\\begin{flushright}"
2172 "\\begin{itemize}"
2173 "\\begin{list}"
2174 "\\begin{minipage}"
2175 "\\begin{picture}"
2176 "\\begin{quotation}"
2177 "\\begin{quote}"
2178 "\\begin{tabbing}"
2179 "\\begin{table}"
2180 "\\begin{tabular}"
2181 "\\begin{thebibliography}"
2182 "\\begin{theorem}"
2183 "\\begin{titlepage}"
2184 "\\begin{verbatim}"
2185 "\\begin{verse}"
2186 "\\bf"
2187 "\\bf"
2188 "\\bibitem"
2189 "\\bigskip"
2190 "\\cdots"
2191 "\\centering"
2192 "\\circle"
2193 "\\cite"
2194 "\\cleardoublepage"
2195 "\\clearpage"
2196 "\\cline"
2197 "\\closing"
2198 "\\dashbox"
2199 "\\date"
2200 "\\ddots"
2201 "\\dotfill"
2202 "\\em"
2203 "\\fbox"
2204 "\\flushbottom"
2205 "\\fnsymbol"
2206 "\\footnote"
2207 "\\footnotemark"
2208 "\\footnotesize"
2209 "\\footnotetext"
2210 "\\frac"
2211 "\\frame"
2212 "\\framebox"
2213 "\\hfill"
2214 "\\hline"
2215 "\\hrulespace"
2216 "\\hspace"
2217 "\\huge"
2218 "\\hyphenation"
2219 "\\include"
2220 "\\includeonly"
2221 "\\indent"
2222 "\\input"
2223 "\\it"
2224 "\\kill"
2225 "\\label"
2226 "\\large"
2227 "\\ldots"
2228 "\\line"
2229 "\\linebreak"
2230 "\\linethickness"
2231 "\\listoffigures"
2232 "\\listoftables"
2233 "\\location"
2234 "\\makebox"
2235 "\\maketitle"
2236 "\\mark"
2237 "\\mbox"
2238 "\\medskip"
2239 "\\multicolumn"
2240 "\\multiput"
2241 ("\\nbsp" "~")
2242 "\\newcommand"
2243 "\\newcounter"
2244 "\\newenvironment"
2245 "\\newfont"
2246 "\\newlength"
2247 "\\newline"
2248 "\\newpage"
2249 "\\newsavebox"
2250 "\\newtheorem"
2251 "\\nocite"
2252 "\\nofiles"
2253 "\\noindent"
2254 "\\nolinebreak"
2255 "\\nopagebreak"
2256 "\\normalsize"
2257 "\\onecolumn"
2258 "\\opening"
2259 "\\oval"
2260 "\\overbrace"
2261 "\\overline"
2262 "\\pagebreak"
2263 "\\pagenumbering"
2264 "\\pageref"
2265 "\\pagestyle"
2266 "\\par"
2267 "\\parbox"
2268 "\\put"
2269 "\\raggedbottom"
2270 "\\raggedleft"
2271 "\\raggedright"
2272 "\\raisebox"
2273 "\\ref"
2274 "\\rm"
2275 "\\roman"
2276 "\\rule"
2277 "\\savebox"
2278 "\\sc"
2279 "\\scriptsize"
2280 "\\setcounter"
2281 "\\setlength"
2282 "\\settowidth"
2283 "\\sf"
2284 "\\shortstack"
2285 "\\signature"
2286 "\\sl"
2287 "\\small"
2288 "\\smallskip"
2289 "\\sqrt"
2290 "\\tableofcontents"
2291 "\\telephone"
2292 "\\thanks"
2293 "\\thispagestyle"
2294 "\\tiny"
2295 "\\title"
2296 "\\tt"
2297 "\\twocolumn"
2298 "\\typein"
2299 "\\typeout"
2300 "\\underbrace"
2301 "\\underline"
2302 "\\usebox"
2303 "\\usecounter"
2304 "\\value"
2305 "\\vdots"
2306 "\\vector"
2307 "\\verb"
2308 "\\vfill"
2309 "\\vline"
2310 "\\vspace")
2311 "A list of LaTeX commands to be protected when performing conversion.")
2313 (defvar org-latex-entities-exceptions nil)
2315 (defconst org-latex-entities-regexp
2316 (let (names rest)
2317 (dolist (x org-latex-entities)
2318 (when (consp x)
2319 (add-to-list 'org-latex-entities-exceptions x)
2320 (setq x (car x)))
2321 (if (string-match "[a-zA-Z]$" x)
2322 (push x names)
2323 (push x rest)))
2324 (concat "\\(" (regexp-opt (nreverse names)) "\\>\\)"
2325 "\\|\\(" (regexp-opt (nreverse rest)) "\\)")))
2327 (provide 'org-export-latex)
2328 (provide 'org-latex)
2330 ;; arch-tag: 23c2b87d-da04-4c2d-ad2d-1eb6487bc3ad
2332 ;;; org-latex.el ends here