emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH 2/5] ox-latex: convert source code and table export to use op


From: Aaron Ecay
Subject: [O] [PATCH 2/5] ox-latex: convert source code and table export to use optional packages
Date: Wed, 20 Feb 2013 23:02:23 -0500

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]