From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: [PATCH] Preserve math environments in title when exporting to LaTeX Date: Sun, 21 Nov 2010 18:18:20 +0100 Message-ID: <801E9991-B59C-4902-8B3B-8DA227F46CFF@gmail.com> References: <87ocai8ekd.fsf@berkeley.edu> <86740850-4B24-406D-A505-0289A50830D2@gmail.com> <0C4982A9-C181-4067-925B-3CEF730AD732@gmail.com> <1CA08B4D-9758-4020-9D7E-E8F842100CA7@tsdye.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=35873 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PKDYb-0005lE-8T for emacs-orgmode@gnu.org; Sun, 21 Nov 2010 12:18:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PKDYZ-0000AI-T4 for emacs-orgmode@gnu.org; Sun, 21 Nov 2010 12:18:29 -0500 Received: from mail-ew0-f41.google.com ([209.85.215.41]:48553) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PKDYZ-0000A9-IV for emacs-orgmode@gnu.org; Sun, 21 Nov 2010 12:18:27 -0500 Received: by ewy25 with SMTP id 25so3521717ewy.0 for ; Sun, 21 Nov 2010 09:18:26 -0800 (PST) In-Reply-To: <1CA08B4D-9758-4020-9D7E-E8F842100CA7@tsdye.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: Richard Lawrence , emacs-orgmode@gnu.org On Nov 21, 2010, at 6:14 PM, Thomas S. Dye wrote: > Aloha Richard and Carsten, > > Thanks very much for this improvement. Math appears to work as > expected in the title and in figure captions. I haven't noticed any > adverse effects yet, but I've spent most of my time admiring the > well typeset titles :) Hi Thomas, thank you for being such a reliable member here. Cheers - Carsten > > All the best, > Tom > > On Nov 20, 2010, at 11:24 PM, Carsten Dominik wrote: > >> >> 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. >> >> THanks >> >> - 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: >>>> http://article.gmane.org/gmane.emacs.orgmode/32281 >>>> >>>> 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!) >>>> >>>> Best, >>>> Richard >>>> >>>> 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-sans-extension >>>> (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))) >>>> (filename >>>> (and (not to-buffer) >>>> (concat >>>> _______________________________________________ >>>> Emacs-orgmode mailing list >>>> Please use `Reply All' to send replies to the list. >>>> Emacs-orgmode@gnu.org >>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >>> >> >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Please use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >