From: Feng Shu <tumashu@gmail.com>
To: emacs-orgmode@gnu.org, carsten.dominik@gmail.com
Subject: Re: [PATCH] Override the default class name with a new one.
Date: Fri, 14 Jun 2013 07:55:09 +0800 [thread overview]
Message-ID: <8761xhftwi.fsf@news.tumashu-localhost.org> (raw)
In-Reply-To: <87hah2wn8y.fsf@news.tumashu-localhost.org> (Feng Shu's message of "Thu, 13 Jun 2013 14:14:37 +0800")
Feng Shu <tumashu@gmail.com> 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,
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
>
> ....
>
> --
>
> 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
--
next prev parent reply other threads:[~2013-06-14 0:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-13 6:14 [PATCH] Override the default class name with a new one Feng Shu
2013-06-13 23:55 ` Feng Shu [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8761xhftwi.fsf@news.tumashu-localhost.org \
--to=tumashu@gmail.com \
--cc=carsten.dominik@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.