summaryrefslogtreecommitdiff
path: root/lisp/org/org-latex.el
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-12-11 17:42:53 +0100
committerCarsten Dominik <carsten.dominik@gmail.com>2010-12-11 17:42:53 +0100
commitacedf35ce08b9df4a0dcbcd1413e7d85f1182034 (patch)
tree240e26f10d2feb66e8c0cd0634082fcb7bd577e5 /lisp/org/org-latex.el
parent39321b94bfa4e50401e30caedfd09a06629f5bd2 (diff)
downloademacs-acedf35ce08b9df4a0dcbcd1413e7d85f1182034.tar.gz
Update to Org mode 7.4
Diffstat (limited to 'lisp/org/org-latex.el')
-rw-r--r--lisp/org/org-latex.el61
1 files changed, 44 insertions, 17 deletions
diff --git a/lisp/org/org-latex.el b/lisp/org/org-latex.el
index 2cf947312d8..a29c9f37401 100644
--- a/lisp/org/org-latex.el
+++ b/lisp/org/org-latex.el
@@ -4,7 +4,7 @@
;;
;; Emacs Lisp Archive Entry
;; Filename: org-latex.el
-;; Version: 7.3
+;; Version: 7.4
;; Author: Bastien Guerry <bzg AT altern DOT org>
;; Maintainer: Carsten Dominik <carsten.dominik AT gmail DOT com>
;; Keywords: org, wp, tex
@@ -295,7 +295,14 @@ markup defined, the first one in the association list will be used."
:group 'org-export-latex
:type 'string)
-(defcustom org-export-latex-hyperref-format "\\href{%s}{%s}"
+(defcustom org-export-latex-href-format "\\href{%s}{%s}"
+ "A printf format string to be applied to href links.
+The format must contain two %s instances. The first will be filled with
+the link, the second with the link description."
+ :group 'org-export-latex
+ :type 'string)
+
+(defcustom org-export-latex-hyperref-format "\\hyperref[%s]{%s}"
"A printf format string to be applied to hyperref links.
The format must contain two %s instances. The first will be filled with
the link, the second with the link description."
@@ -453,12 +460,6 @@ pygmentize -L lexers
(symbol :tag "Major mode ")
(string :tag "Listings language"))))
-(defcustom org-export-latex-minted-with-line-numbers nil
- "Should source code line numbers be included when exporting
-with the latex minted package?"
- :group 'org-export-latex
- :type 'boolean)
-
(defcustom org-export-latex-remove-from-headlines
'(:todo nil :priority nil :tags nil)
"A plist of keywords to remove from headlines. OBSOLETE.
@@ -1280,12 +1281,13 @@ OPT-PLIST is the options plist for current buffer."
(org-export-apply-macros-in-string org-export-latex-append-header)
;; define alert if not yet defined
"\n\\providecommand{\\alert}[1]{\\textbf{#1}}"
+ ;; beginning of the document
+ "\n\\begin{document}\n\n"
;; insert the title
(format
"\n\n\\title{%s}\n"
;; convert the title
- (org-export-latex-content
- title '(lists tables fixed-width keywords)))
+ (org-export-latex-fontify-headline title))
;; insert author info
(if (plist-get opt-plist :author-info)
(format "\\author{%s}\n"
@@ -1297,8 +1299,6 @@ OPT-PLIST is the options plist for current buffer."
(format-time-string
(or (plist-get opt-plist :date)
org-export-latex-date-format)))
- ;; beginning of the document
- "\n\\begin{document}\n\n"
;; insert the title command
(when (string-match "\\S-" title)
(if (string-match "%s" org-export-latex-title-command)
@@ -1325,7 +1325,7 @@ If END is non-nil, it is the end of the region."
(save-excursion
(goto-char (or beg (point-min)))
(let* ((pt (point))
- (end (if (re-search-forward "^\\*+ " end t)
+ (end (if (re-search-forward (org-get-limited-outline-regexp) end t)
(goto-char (match-beginning 0))
(goto-char (or end (point-max))))))
(prog1
@@ -1452,6 +1452,33 @@ links, keywords, lists, tables, fixed-width"
;; FIXME: org-inside-LaTeX-fragment-p doesn't work when the $...$ is at
;; the beginning of the buffer - inserting "\n" is safe here though.
(insert "\n" string)
+
+ ;; Preserve math snippets
+
+ (let* ((matchers (plist-get org-format-latex-options :matchers))
+ (re-list org-latex-regexps)
+ beg end re e m n block off)
+ ;; Check the different regular expressions
+ (while (setq e (pop re-list))
+ (setq m (car e) re (nth 1 e) n (nth 2 e)
+ block (if (nth 3 e) "\n\n" ""))
+ (setq off (if (member m '("$" "$1")) 1 0))
+ (when (and (member m matchers) (not (equal m "begin")))
+ (goto-char (point-min))
+ (while (re-search-forward re nil t)
+ (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
+ (add-text-properties beg end
+ '(org-protected t org-latex-math t))))))
+
+ ;; Convert LaTeX to \LaTeX{} and TeX to \TeX{}
+ (goto-char (point-min))
+ (let ((case-fold-search nil))
+ (while (re-search-forward "\\<\\(\\(La\\)?TeX\\)\\>" nil t)
+ (unless (eq (char-before (match-beginning 1)) ?\\)
+ (org-if-unprotected-1
+ (replace-match (org-export-latex-protect-string
+ (concat "\\" (match-string 1)
+ "{}")) t t)))))
(goto-char (point-min))
(let ((re (concat "\\\\\\([a-zA-Z]+\\)"
"\\(?:<[^<>\n]*>\\)*"
@@ -2016,10 +2043,10 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(insert (format
(org-export-get-coderef-format path desc)
(cdr (assoc path org-export-code-refs)))))
- (radiop (insert (format "\\hyperref[%s]{%s}"
+ (radiop (insert (format org-export-latex-hyperref-format
(org-solidify-link-text raw-path) desc)))
((not type)
- (insert (format "\\hyperref[%s]{%s}"
+ (insert (format org-export-latex-hyperref-format
(org-remove-initial-hash
(org-solidify-link-text raw-path))
desc)))
@@ -2030,7 +2057,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
;; a LaTeX issue, but we here implement a work-around anyway.
(setq path (org-export-latex-protect-amp path)
desc (org-export-latex-protect-amp desc)))
- (insert (format org-export-latex-hyperref-format path desc)))
+ (insert (format org-export-latex-href-format path desc)))
((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
;; The link protocol has a function for formatting the link
@@ -2356,7 +2383,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
"\n"
(match-string 1 res))
t t res)))
- (insert res "\n"))))
+ (insert res))))
(defconst org-latex-entities
'("\\!"