#+LATEX_CLASS: article

%%output:

\documentclass[11pt]{article}

...

--------------------------------------

#+LATEX_CLASS: article
#+LATEX_CLASS_NAME: ctexart

%%output:

\documentclass[11pt]{ctexart}

....

-- 
>From 338ce85c306ae400ba8c62bfaecaf8973346faa0 Mon Sep 17 00:00:00 2001
From: Feng Shu <tuma...@gmail.com>
Date: Thu, 13 Jun 2013 13:36:50 +0800
Subject: [PATCH] Override the default latex class name with a new one

* lisp/ox-latex.el (latex): Add :latex-class-name to :options-alist.
(org-latex-default-latex-class-name): The default name of LaTeX class file.
(org-latex-template): Replace default latex class name with :latex-class-name.

Override  the default latex class name in template. It will be very
useful if you are using a class and it's setting is very similar to
one which has been defined in the `org-latex-classes, for example:

If you want to use latex class: "ctexart"  and you find that it's
setting will be very similar to "article", you don't need to add a
new list to `org-latex-classes, just type:

#+LATEX_CLASS: article
#+LATEX_CLASS_NAME: ctexart
---
 lisp/ox-latex.el |   16 ++++++++++++++--
 1 个文件被修改,插入 14 行(+),删除 2 行(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9172cd7..ecfb0ce 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -98,6 +98,7 @@
 	      (if a (org-latex-export-to-pdf t s v b)
 		(org-open-file (org-latex-export-to-pdf nil s v b)))))))
   :options-alist '((:latex-class "LATEX_CLASS" nil org-latex-default-class t)
+		   (:latex-class-name "LATEX_CLASS_NAME" nil org-latex-default-latex-class-name t)
 		   (:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t)
 		   (:latex-header "LATEX_HEADER" nil nil newline)
 		   (:latex-header-extra "LATEX_HEADER_EXTRA" nil nil newline)
@@ -182,6 +183,11 @@
   :group 'org-export-latex
   :type '(string :tag "LaTeX class"))
 
+(defcustom org-latex-default-latex-class-name ""
+  "The default name  of LaTeX class file."
+  :group 'org-export-latex
+  :type '(string :tag "LaTeX class"))
+
 (defcustom org-latex-classes
   '(("article"
      "\\documentclass[11pt]{article}"
@@ -1061,15 +1067,21 @@ holding export options."
 	  (format-time-string "%% Created %Y-%m-%d %a %H:%M\n"))
      ;; Document class and packages.
      (let ((class (plist-get info :latex-class))
+	   (latex-class-name (plist-get info :latex-class-name))
 	   (class-options (plist-get info :latex-class-options)))
        (org-element-normalize-string
 	(let* ((header (nth 1 (assoc class org-latex-classes)))
-	       (document-class-string
+	       (document-class-string-tmp
 		(and (stringp header)
 		     (if (not class-options) header
 		       (replace-regexp-in-string
 			"^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)"
-			class-options header t nil 1)))))
+			class-options header t nil 1))))
+	       (document-class-string
+		     (if (not latex-class-name) document-class-string-tmp
+		       (replace-regexp-in-string
+			"^[ \t]*\\\\documentclass\\[[^]]*\\]?{\\(.*\\)}"
+			latex-class-name document-class-string-tmp t nil 1))))
 	  (if (not document-class-string)
 	      (user-error "Unknown LaTeX class `%s'" class)
 	    (org-latex-guess-babel-language
-- 
1.7.10.4

Reply via email to