From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: [PATCH 2/5] ox-latex: convert source code and table export to use optional packages Date: Wed, 20 Feb 2013 23:02:23 -0500 Message-ID: <1361419346-23146-3-git-send-email-aaronecay@gmail.com> References: <1361419346-23146-1-git-send-email-aaronecay@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8NMw-0001OH-Ep for emacs-orgmode@gnu.org; Wed, 20 Feb 2013 23:02:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8NMu-00037w-O4 for emacs-orgmode@gnu.org; Wed, 20 Feb 2013 23:02:50 -0500 Received: from mail-vb0-f45.google.com ([209.85.212.45]:38597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8NMu-00037q-Iq for emacs-orgmode@gnu.org; Wed, 20 Feb 2013 23:02:48 -0500 Received: by mail-vb0-f45.google.com with SMTP id p1so5534426vbi.32 for ; Wed, 20 Feb 2013 20:02:47 -0800 (PST) In-Reply-To: <1361419346-23146-1-git-send-email-aaronecay@gmail.com> 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 This eliminates the unconditional use of longtable in ‘org-latex-default-packages-alist,’ and also allows the use of listings, minted, and booktabs packages to be simplified (users no longer need to add them to ‘org-latex-packages-alist’; they are automatically imported if needed). --- lisp/org.el | 1 - lisp/ox-latex.el | 47 +++++++++++++++++++---------------------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 1d83aa4..d3506d1 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3753,7 +3753,6 @@ header, or they will be appended." ("T1" "fontenc" t) ("" "fixltx2e" nil) ("" "graphicx" t) - ("" "longtable" nil) ("" "float" nil) ("" "wrapfig" nil) ("" "soul" t) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 9895028..100de1d 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -569,10 +569,8 @@ When modifying this variable, it may be useful to change (defcustom org-latex-tables-booktabs nil "When non-nil, display tables in a formal \"booktabs\" style. -This option assumes that the \"booktabs\" package is properly -loaded in the header of the document. This value can be ignored -locally with \":booktabs t\" and \":booktabs nil\" LaTeX -attributes." +This value can be ignored locally with \":booktabs t\" and +\":booktabs nil\" LaTeX attributes." :group 'org-export-latex :type 'boolean) @@ -688,29 +686,9 @@ in order to mimic default behaviour: (defcustom org-latex-listings nil "Non-nil means export source code using the listings package. -This package will fontify source code, possibly even with color. -If you want to use this, you also need to make LaTeX use the -listings package, and if you want to have color, the color -package. Just add these to `org-latex-packages-alist', for -example using customize, or with something like: - - \(require 'ox-latex) - \(add-to-list 'org-latex-packages-alist '\(\"\" \"listings\")) - \(add-to-list 'org-latex-packages-alist '\(\"\" \"color\")) - -Alternatively, - - \(setq org-latex-listings 'minted) - -causes source code to be exported using the minted package as -opposed to listings. If you want to use minted, you need to add -the minted package to `org-latex-packages-alist', for example -using customize, or with - - \(require 'ox-latex) - \(add-to-list 'org-latex-packages-alist '\(\"\" \"minted\")) - -In addition, it is necessary to install pygments +This package will fontify source code, possibly even with color, +using the minted or listings LaTeX packages. If you want to use +minted, it is necessary to install pygments \(http://pygments.org), and to configure the variable `org-latex-pdf-process' so that the -shell-escape option is passed to pdflatex." @@ -1621,6 +1599,7 @@ contextual information." (concat "\\verb" separator code separator)) ;; Use minted package. ((eq org-latex-listings 'minted) + (org-latex--use-package info "minted") (let* ((org-lang (org-element-property :language inline-src-block)) (mint-lang (or (cadr (assq (intern org-lang) org-latex-minted-langs)) @@ -1633,6 +1612,8 @@ contextual information." separator code separator))) ;; Use listings package. (t + (org-latex--use-package info "listings") + (org-latex--use-package info "color") ;; Maybe translate language's name. (let* ((org-lang (org-element-property :language inline-src-block)) (lst-lang (or (cadr (assq (intern org-lang) @@ -2169,6 +2150,7 @@ contextual information." custom-env)) ;; Case 3. Use minted package. ((eq org-latex-listings 'minted) + (org-latex--use-package info "minted") (let ((float-env (when (or label caption) (format "\\begin{listing}[H]\n%%s\n%s\\end{listing}" @@ -2208,6 +2190,8 @@ contextual information." (if float-env (format float-env body) body))) ;; Case 4. Use listings package. (t + (org-latex--use-package info "listings") + (org-latex--use-package info "color") (let ((lst-lang (or (cadr (assq (intern lang) org-latex-listings-langs)) lang)) (caption-str @@ -2436,7 +2420,14 @@ This function assumes TABLE has `org' as its `:type' property and (placement (or (plist-get attr :placement) (format "[%s]" org-latex-default-figure-position))) (centerp (if (plist-member attr :center) (plist-get attr :center) - org-latex-tables-centered))) + org-latex-tables-centered)) + (booktabsp (if (plist-member attr :booktabs) + (plist-get attr :booktabs) + org-latex-tables-booktabs))) + (when (equal "longtable" table-env) + (org-latex--use-package info "longtable")) + (when booktabsp + (org-latex--use-package info "booktabs")) ;; Prepare the final format string for the table. (cond ;; Longtable. -- 1.8.1.4