>From 54bcf8f1ae26c91fa856b64071dca65d3f31e1f2 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Wed, 8 Jul 2015 14:44:56 +0200 Subject: [PATCH 9/9] ox-latex: Support TeX variants * org.el (org-latex-default-packages-alist): Only use inputenc and fontenc in pdftex. * ox-latex.el (latex): Add :latex-tex-variant. (org-latex-tex-variant): New defcustom. (org-latex--remove-packages): New function. (org-latex-template): Use new function. --- lisp/org.el | 4 ++-- lisp/ox-latex.el | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index f10ccf9..3324138 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -4069,8 +4069,8 @@ header, or they will be appended." (default-value var))) (defcustom org-latex-default-packages-alist - '(("AUTO" "inputenc" t) - ("T1" "fontenc" t) + '(("AUTO" "inputenc" t pdftex) + ("T1" "fontenc" t pdftex) ("" "graphicx" t) ("" "grffile" t) ("" "longtable" nil) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 058d7f8..e7337e1 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -144,6 +144,7 @@ (:latex-text-markup-alist nil nil org-latex-text-markup-alist) (:latex-title-command nil nil org-latex-title-command) (:latex-toc-command nil nil org-latex-toc-command) + (:latex-tex-variant nil "tex-variant" org-latex-tex-variant) ;; Redefine regular options. (:date "DATE" nil "\\today" parse))) @@ -305,6 +306,16 @@ references." :version "25.1" :package-version '(Org . "8.3")) +(defcustom org-latex-tex-variant 'pdftex + "Tex variant to use." + :group 'org-export-latex + :type '(choice + (cons :tag "pdfTeX" pdftex) + (cons :tag "XeTeX" xetex) + (cons :tag "luaTeX" luatex)) + :version "25.1" + :package-version '(Org . "8.3")) + ;;;; Preamble (defcustom org-latex-default-class "article" @@ -1234,6 +1245,24 @@ Return the new header." (format "\n\\setotherlanguage{%s}\n" (mapconcat 'identity languages ", ")))) t t header 0))))) +(defun org-latex--remove-packages (pkg-alist info) + "Remove packages based on the current TeX variant. + +If the fourth argument of an element is set in pkg-alist, and it +is not a member of the tex variant of the document, the packages +is removed. See also `org-latex-tex-variant'. + +Return modified pkg-alist." + (delq nil + (mapcar (lambda (pkg) + (unless (and (listp pkg) + (let ((third (nth 3 pkg))) + (and third + (not (member (plist-get info :latex-tex-variant) + (if (listp third) third (list third))))))) + pkg)) + pkg-alist))) + (defun org-latex--find-verb-separator (s) "Return a character not used in string S. This is used to choose a separator for constructs like \\verb." @@ -1394,8 +1423,9 @@ holding export options." (org-element-normalize-string (org-splice-latex-header document-class-string - org-latex-default-packages-alist - org-latex-packages-alist nil + (org-latex--remove-packages org-latex-default-packages-alist info) + (org-latex--remove-packages org-latex-packages-alist info) + nil (concat (org-element-normalize-string (plist-get info :latex-header)) (plist-get info :latex-header-extra))))) -- 2.4.5