Bastien <[email protected]> writes:

> I don't know but it looks good to me, because the shortcomings of
> \underline not being able to wrap are not a problem for sections.

Here is the patch. b399ff0cba2382bf52d5bb6ef2b4a776fe0ac902 needs to be
reverted first.


Regards,

-- 
Nicolas Goaziou
>From 7a6bcad9dea5dd8a7c8b15f942191046f63f262f Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <[email protected]>
Date: Sat, 22 Mar 2014 14:23:23 +0100
Subject: [PATCH] ox-latex: Fix underline in sections

* lisp/ox-latex.el (org-latex-headline): Hard-code "\underline" in
  sections because "\uline" ("ulem" package) returns an error and
  "\ul" ("soul" package) doesn't support chinese characters.

See http://permalink.gmane.org/gmane.emacs.orgmode/83962 for the
related thread.
---
 lisp/ox-latex.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 3d51ce5..b49a157 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1344,7 +1344,16 @@ holding contextual information."
 	       ((= (length sec) 4)
 		(if numberedp (concat (car sec) "\n%s" (nth 1 sec))
 		  (concat (nth 2 sec) "\n%s" (nth 3 sec)))))))
-	   (text (org-export-data (org-element-property :title headline) info))
+	   ;; Create a temporary export back-end that hard-codes
+	   ;; "\underline" within "\section" and alike.
+	   (section-back-end
+	    (org-export-create-backend
+	     :parent 'latex
+	     :transcoders
+	     '((underline . (lambda (o c i) (format "\\underline{%s}" c))))))
+	   (text
+	    (org-export-data-with-backend
+	     (org-element-property :title headline) section-back-end info))
 	   (todo
 	    (and (plist-get info :with-todo-keywords)
 		 (let ((todo (org-element-property :todo-keyword headline)))
@@ -1397,8 +1406,9 @@ holding contextual information."
 	(let ((opt-title
 	       (funcall org-latex-format-headline-function
 			todo todo-type priority
-			(org-export-data
-			 (org-export-get-alt-title headline info) info)
+			(org-export-data-with-backend
+			 (org-export-get-alt-title headline info)
+			 section-back-end info)
 			(and (eq (plist-get info :with-tags) t) tags))))
 	  (if (and numberedp opt-title
 		   (not (equal opt-title full-text))
-- 
1.9.1

Reply via email to