emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <1361419346-23146-3-git-send-email-aaronecay@gmail.com> (raw)
In-Reply-To: <1361419346-23146-1-git-send-email-aaronecay@gmail.com>

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

  parent reply	other threads:[~2013-02-21  4:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-21  4:02 [RFC] [PATCH] conditional use of latex packages Aaron Ecay
2013-02-21  4:02 ` [PATCH 1/5] ox-latex: add optional-packages machinery Aaron Ecay
2013-02-21  4:02 ` Aaron Ecay [this message]
2013-02-21  4:02 ` [PATCH 3/5] ob-R: change the file extension for tikz figures Aaron Ecay
2013-02-21  4:02 ` [PATCH 4/5] ox-latex: Treat tikz files as images Aaron Ecay
2013-02-21  4:02 ` [PATCH 5/5] ox-latex: Convert the image inclusion code to use optional packages Aaron Ecay
2013-02-21  9:51 ` [RFC] [PATCH] conditional use of latex packages Suvayu Ali
2013-02-21 15:19 ` Nicolas Goaziou
2013-02-21 17:33   ` Aaron Ecay
2013-02-21 18:39     ` Nicolas Goaziou
2013-02-24 18:47       ` Aaron Ecay
2013-02-24 18:50         ` [PATCH] ox-latex: add optional-packages machinery Aaron Ecay

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1361419346-23146-3-git-send-email-aaronecay@gmail.com \
    --to=aaronecay@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).