emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Richard Lawrence <richard.lawrence@berkeley.edu>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Preserve math environments in title when exporting to LaTeX
Date: Mon, 25 Oct 2010 08:41:54 -0700	[thread overview]
Message-ID: <87ocai8ekd.fsf@berkeley.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Preserve math environments in title --]
[-- Type: text/x-diff, Size: 1436 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

             reply	other threads:[~2010-10-25 15:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-25 15:41 Richard Lawrence [this message]
2010-11-21  8:54 ` [PATCH] Preserve math environments in title when exporting to LaTeX Carsten Dominik
2010-11-21  9:23   ` Kirsten
2010-11-21  9:24   ` Carsten Dominik
2010-11-21 17:14     ` Thomas S. Dye
2010-11-21 17:18       ` Carsten Dominik
2010-11-22  6:11     ` Richard Lawrence
2010-11-22  9:36     ` Eric S Fraga
2010-11-22 18:09       ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ocai8ekd.fsf@berkeley.edu \
    --to=richard.lawrence@berkeley.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).