瀏覽代碼

Allow LaTeX_CLASS_OPTIONS to set options, also from a property

Carsten Dominik 15 年之前
父節點
當前提交
d5230f0ec7
共有 3 個文件被更改,包括 28 次插入2 次删除
  1. 4 0
      lisp/ChangeLog
  2. 22 1
      lisp/org-latex.el
  3. 2 1
      lisp/org.el

+ 4 - 0
lisp/ChangeLog

@@ -1,7 +1,11 @@
 2009-11-27  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-latex.el (org-export-latex-class-options): New variable.
+	(org-export-latex-set-initial-vars): Use the class options.
+
 	* org.el (org-forward-same-level): Stop at headings that start
 	with an invisible character.
+	(org-additional-option-like-keywords): Add LaTeX_CLASS_OPTIONS.
 
 	* org-clock.el (org-clock-in): Do not restart the clock in the
 	same entry where it is running now.

+ 22 - 1
lisp/org-latex.el

@@ -53,6 +53,7 @@
 
 ;;; Variables:
 (defvar org-export-latex-class nil)
+(defvar org-export-latex-class-options nil)
 (defvar org-export-latex-header nil)
 (defvar org-export-latex-append-header nil)
 (defvar org-export-latex-options-plist nil)
@@ -935,6 +936,19 @@ LEVEL indicates the default depth for export."
 		     (match-string 1))))
 	    (plist-get org-export-latex-options-plist :latex-class)
 	    org-export-latex-default-class)
+	org-export-latex-class-options
+	(or (and (org-region-active-p)
+		 (save-excursion
+		   (goto-char (region-beginning))
+		   (and (looking-at org-complex-heading-regexp)
+			(org-entry-get nil "LaTeX_CLASS_OPTIONS" 'selective))))
+	    (save-excursion
+	      (save-restriction
+		(widen)
+		(goto-char (point-min))
+		(and (re-search-forward "^#\\+LaTeX_CLASS_OPTIONS:[ \t]*\\(.*?\\)[ \t]*$" nil t)
+		     (match-string 1))))
+	    (plist-get org-export-latex-options-plist :latex-class-options))
 	org-export-latex-class
 	(or (car (assoc org-export-latex-class org-export-latex-classes))
 	    (error "No definition for class `%s' in `org-export-latex-classes'"
@@ -948,7 +962,14 @@ LEVEL indicates the default depth for export."
 	    (let ((hl-levels
 		   (plist-get org-export-latex-options-plist :headline-levels))
 		  (sec-depth (length org-export-latex-sectioning)))
-	      (if (> hl-levels sec-depth) sec-depth hl-levels)))))
+	      (if (> hl-levels sec-depth) sec-depth hl-levels))))
+  (when (and org-export-latex-class-options
+	     (string-match "\\S-" org-export-latex-class-options)
+	     (string-match "^[ \t]*\\(\\\\documentclass\\)\\(\\[.*?\\]\\)?" org-export-latex-header))
+    (setq org-export-latex-header
+	  (concat (substring org-export-latex-header 0 (match-end 1))
+		  org-export-latex-class-options
+		  (substring org-export-latex-header (match-end 0))))))
 
 (defun org-export-latex-make-header (title opt-plist)
   "Make the LaTeX header and return it as a string.

+ 2 - 1
lisp/org.el

@@ -9481,7 +9481,8 @@ This function can be used in a hook."
 (defconst org-additional-option-like-keywords
   '("BEGIN_HTML"  "END_HTML"  "HTML:" "ATTR_HTML"
     "BEGIN_DocBook"  "END_DocBook"  "DocBook:" "ATTR_DocBook"
-    "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:" "LATEX_CLASS:" "ATTR_LaTeX"
+    "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:"
+    "LATEX_CLASS:" "LATEX_CLASS_OPTIONS:" "ATTR_LaTeX"
     "BEGIN:" "END:"
     "ORGTBL" "TBLFM:" "TBLNAME:"
     "BEGIN_EXAMPLE" "END_EXAMPLE"