From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: Re: [PATCH] Override the default class name with a new one. Date: Fri, 14 Jun 2013 07:55:09 +0800 Message-ID: <8761xhftwi.fsf@news.tumashu-localhost.org> References: <87hah2wn8y.fsf@news.tumashu-localhost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnI82-0004af-Cu for emacs-orgmode@gnu.org; Thu, 13 Jun 2013 20:44:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnI81-0006nw-5A for emacs-orgmode@gnu.org; Thu, 13 Jun 2013 20:44:34 -0400 Received: from mail-pb0-x232.google.com ([2607:f8b0:400e:c01::232]:36592) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnI80-0006nk-Rw for emacs-orgmode@gnu.org; Thu, 13 Jun 2013 20:44:33 -0400 Received: by mail-pb0-f50.google.com with SMTP id wz7so5353330pbc.37 for ; Thu, 13 Jun 2013 17:44:31 -0700 (PDT) In-Reply-To: <87hah2wn8y.fsf@news.tumashu-localhost.org> (Feng Shu's message of "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: emacs-orgmode@gnu.org, carsten.dominik@gmail.com Feng Shu writes: > #+LATEX_CLASS: article > > %%output: > > \documentclass[11pt]{article} > > ... > > -------------------------------------- > > #+LATEX_CLASS: article > #+LATEX_CLASS_NAME: ctexart > > %%output: > > \documentclass[11pt]{ctexart} Hi: If possible, please merge this patch to master, thanks! I think it is a way reusing the exist class defines in `org-latex-classes If your class is similar with a exist one,=20 For example: #+begin_example ("article" "\\documentclass[11pt]{article}" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) ("ctexart" "\\documentclass[11pt]{ctexart}" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\subparagraph{%s}" . "\\subparagraph*{%s}")) #+end_example You don't need to add "ctexart" to `org-latex-classes, just type: #+LATEX_CLASS: article #+LATEX_CLASS_NAME: ctexart > > .... > > --=20 > > 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 fil= e. > (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 =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-cla= ss t) > + (:latex-class-name "LATEX_CLASS_NAME" nil org-latex-default-latex-c= lass-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=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