From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: [PATCH] Override the default class name with a new one. Date: Thu, 13 Jun 2013 14:14:37 +0800 Message-ID: <87hah2wn8y.fsf@news.tumashu-localhost.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Un0pc-00009i-SU for emacs-orgmode@gnu.org; Thu, 13 Jun 2013 02:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Un0pb-00050N-JH for emacs-orgmode@gnu.org; Thu, 13 Jun 2013 02:16:24 -0400 Received: from mail-pb0-x22c.google.com ([2607:f8b0:400e:c01::22c]:34418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Un0pb-00050A-Cj for emacs-orgmode@gnu.org; Thu, 13 Jun 2013 02:16:23 -0400 Received: by mail-pb0-f44.google.com with SMTP id uo1so5252713pbc.3 for ; Wed, 12 Jun 2013 23:16:22 -0700 (PDT) Received: from tumashu ([110.97.80.225]) by mx.google.com with ESMTPSA id xj9sm15585504pbc.16.2013.06.12.23.16.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 12 Jun 2013 23:16:21 -0700 (PDT) Received: from feng by tumashu with local (Exim 4.80) (envelope-from ) id 1Un0nt-0003Kh-6v for emacs-orgmode@gnu.org; Thu, 13 Jun 2013 14:14:37 +0800 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: orgmode --=-=-= Content-Type: text/plain #+LATEX_CLASS: article %%output: \documentclass[11pt]{article} ... -------------------------------------- #+LATEX_CLASS: article #+LATEX_CLASS_NAME: ctexart %%output: \documentclass[11pt]{ctexart} .... -- --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-Override-the-default-latex-class-name-with-a-new-one.patch Content-Transfer-Encoding: quoted-printable >From 338ce85c306ae400ba8c62bfaecaf8973346faa0 Mon Sep 17 00:00:00 2001 From: Feng Shu 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-na= me. 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 =E4=B8=AA=E6=96=87=E4=BB=B6=E8=A2=AB=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=8F=92= =E5=85=A5 14 =E8=A1=8C(+)=EF=BC=8C=E5=88=A0=E9=99=A4 2 =E8=A1=8C(-) 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-cla= ss-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")) =20 +(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 --=20 1.7.10.4 --=-=-=--