[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] [PATCH] Preserve math environments in title when exporting

From: Kirsten
Subject: Re: [Orgmode] [PATCH] Preserve math environments in title when exporting to LaTeX
Date: Sun, 21 Nov 2010 10:23:39 +0100

On Nov 21, 2010, at 9:54 AM, Carsten Dominik wrote:

Hi Richard,

I have now applied this patch. I am not entirely sure it will have no adverse effects, so please, people who do export to LaTeX, check after the next pull if you see any problems.

Actually, I think I have just found a better way to solve this issue,
in a way that will also solve it for figure captions.

Please, LaTeX export users, test the current git version.


- Carsten

Thanks Richard!

- Carsten

On Oct 25, 2010, at 5:41 PM, Richard Lawrence wrote:

Hi all,

This patch fixes the issue I originally described here:

It preserves math-mode delimiters (e.g. "$" and "\(") in the document
title when exporting to LaTeX.  (That is, it prevents them from being
escaped, by running the title through org-export-preprocess-string,
which marks them with the org-protected property.)  It should work
regardless of whether the title is pulled from a headline, from the text
before the first headline, or from an explicit #+TITLE declaration.

(This is my first time contributing a patch to a Free Software project
-- so please, let me know what you think!)


diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 4fcbbb7..f97436c 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -727,13 +727,33 @@ when PUB-DIR is set, use this as the publishing directory."
         (org-current-export-file buffer-file-name)
         (title (or (and subtree-p (org-export-get-title-from-subtree))
                    (plist-get opt-plist :title)
-                   (and (not
-                         (plist-get opt-plist :skip-before-1st-heading))
-                        (org-export-grab-title-from-buffer))
+                   (unless (plist-get opt-plist :skip-before-1st-heading)
+                     (let ((pt (org-export-grab-title-from-buffer)))
+                       (remove-text-properties 0 (length pt)
+                                               '(:org-license-to-kill t) pt)
+                       pt))
                    (and buffer-file-name
                          (file-name-nondirectory buffer-file-name)))
                    "No Title"))
+        ; Preprocessing preserves math environments in title
+        (title
+         (and title (string-match "\\S-" title)
+              (org-export-preprocess-string
+               title
+               :emph-multiline t
+               :for-LaTeX t
+               :comments nil
+               :tags (plist-get opt-plist :tags)
+               :priority (plist-get opt-plist :priority)
+               :footnotes (plist-get opt-plist :footnotes)
+               :drawers (plist-get opt-plist :drawers)
+               :timestamps (plist-get opt-plist :timestamps)
+               :todo-keywords (plist-get opt-plist :todo-keywords)
+               :add-text nil
+               :select-tags nil
+               :exclude-tags nil
+               :LaTeX-fragments nil)))
          (and (not to-buffer)
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]