emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Override the default class name with a new one.
@ 2013-06-13  6:14 Feng Shu
  2013-06-13 23:55 ` Feng Shu
  2013-06-14 13:36 ` Nicolas Goaziou
  0 siblings, 2 replies; 12+ messages in thread
From: Feng Shu @ 2013-06-13  6:14 UTC (permalink / raw)
  To: orgmode

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


#+LATEX_CLASS: article

%%output:

\documentclass[11pt]{article}

...

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

#+LATEX_CLASS: article
#+LATEX_CLASS_NAME: ctexart

%%output:

\documentclass[11pt]{ctexart}

....

-- 

[-- Attachment #2: 0001-Override-the-default-latex-class-name-with-a-new-one.patch --]
[-- Type: text/x-diff, Size: 3077 bytes --]

From 338ce85c306ae400ba8c62bfaecaf8973346faa0 Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-06-18 22:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-13  6:14 [PATCH] Override the default class name with a new one Feng Shu
2013-06-13 23:55 ` Feng Shu
2013-06-14  9:13   ` Rasmus
2013-06-14  9:50     ` Nick Dokos
2013-06-14 10:09       ` Rasmus
2013-06-14 10:42       ` Feng Shu
2013-06-14  9:55     ` Feng Shu
2013-06-14 11:50       ` Suvayu Ali
2013-06-14 13:36 ` Nicolas Goaziou
2013-06-14 15:13   ` Feng Shu
2013-06-18 19:34     ` Nicolas Goaziou
2013-06-18 22:33       ` Rasmus

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).