emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch] ox-latex.el to allow customization of verbatim environments (e.g., to use fancyvrb)
@ 2013-04-14 17:48 Eric Schulte
  2013-04-14 19:26 ` Nicolas Goaziou
  2013-04-14 20:02 ` Daimrod
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Schulte @ 2013-04-14 17:48 UTC (permalink / raw)
  To: Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 74 bytes --]

Please see the attached patch, I'd love for this to be applied.

Cheers,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-customizable-verbatim-export-for-LaTeX-fancyvrb.patch --]
[-- Type: text/x-patch, Size: 4345 bytes --]

From 04358f2eecf99e43f79956f0d3bc66aa0ab4b95d Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
Date: Sun, 14 Apr 2013 11:43:30 -0600
Subject: [PATCH 3/3] customizable verbatim export for LaTeX (fancyvrb)

  This patch allows custom export of verbatim environments to LaTeX.
  Allowing the usage of packages such as fancyvrb.

* lisp/ox-latex.el (org-latex-verbatim-env): New defcustom allowing
  customization of verbatim export for latex.
  (org-latex-example-block): Use new defcustom verbatim environment.
  (org-latex-fixed-width): Use new defcustom verbatim environment.
  (org-latex-quote-section): Use new defcustom verbatim environment.
  (org-latex-src-block): Use new defcustom verbatim environment.
  (org-latex-table): Use new defcustom verbatim environment.
---
 lisp/ox-latex.el | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5975ce2..91747c3 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -957,6 +957,14 @@ log of a latex-run."
 	   (string :tag "Regexp")
 	   (string :tag "Message"))))
 
+(defcustom org-latex-verbatim-env
+  "verbatim"
+  "Environment to use for verbatim markup in latex export.
+To use the fancyvrb package set this variable to \"Verbatim\"."
+  :group 'org-export-latex
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type 'string)
 
 \f
 ;;; Internal Functions
@@ -1320,8 +1328,10 @@ information."
   (when (org-string-nw-p (org-element-property :value example-block))
     (org-latex--wrap-label
      example-block
-     (format "\\begin{verbatim}\n%s\\end{verbatim}"
-	     (org-export-format-code-default example-block info)))))
+     (format "\\begin{%s}\n%s\\end{%s}"
+	     org-latex-verbatim-env
+	     (org-export-format-code-default example-block info)
+	     org-latex-verbatim-env))))
 
 
 ;;;; Export Block
@@ -1349,9 +1359,11 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 CONTENTS is nil.  INFO is a plist holding contextual information."
   (org-latex--wrap-label
    fixed-width
-   (format "\\begin{verbatim}\n%s\\end{verbatim}"
+   (format "\\begin{%s}\n%s\\end{%s}"
+	   org-latex-verbatim-env
 	   (org-remove-indentation
-	    (org-element-property :value fixed-width)))))
+	    (org-element-property :value fixed-width))
+	   org-latex-verbatim-env)))
 
 
 ;;;; Footnote Reference
@@ -2098,8 +2110,8 @@ holding contextual information."
 CONTENTS is nil.  INFO is a plist holding contextual information."
   (let ((value (org-remove-indentation
 		(org-element-property :value quote-section))))
-    (when value (format "\\begin{verbatim}\n%s\\end{verbatim}" value))))
-
+    (when value (format "\\begin{%s}\n%s\\end{%s}"
+			org-latex-verbatim-env value org-latex-verbatim-env))))
 
 ;;;; Radio Target
 
@@ -2171,8 +2183,10 @@ contextual information."
 				       caption-str))))
 	  (format
 	   (or float-env "%s")
-	   (concat (format "\\begin{verbatim}\n%s\\end{verbatim}"
-			   (org-export-format-code-default src-block info))))))
+	   (concat (format "\\begin{%s}\n%s\\end{%s}"
+			   org-latex-verbatim-env
+			   (org-export-format-code-default src-block info)
+			   org-latex-verbatim-env)))))
        ;; Case 2.  Custom environment.
        (custom-env (format "\\begin{%s}\n%s\\end{%s}\n"
 			   custom-env
@@ -2377,10 +2391,12 @@ contextual information."
       (cond
        ;; Case 1: Verbatim table.
        ((string= type "verbatim")
-	(format "\\begin{verbatim}\n%s\n\\end{verbatim}"
+	(format "\\begin{%s}\n%s\n\\end{%s}"
+		org-latex-verbatim-env
 		;; Re-create table, without affiliated keywords.
 		(org-trim (org-element-interpret-data
-			   `(table nil ,@(org-element-contents table))))))
+			   `(table nil ,@(org-element-contents table))))
+		org-latex-verbatim-env))
        ;; Case 2: Matrix.
        ((or (string= type "math") (string= type "inline-math"))
 	(org-latex--math-table table info))
@@ -2741,8 +2757,8 @@ holding contextual information."
   "Transcode a VERBATIM object from Org to LaTeX.
 CONTENTS is nil.  INFO is a plist used as a communication
 channel."
-  (org-latex--text-markup (org-element-property :value verbatim) 'verbatim))
-
+  (org-latex--text-markup (org-element-property :value verbatim)
+			  org-latex-verbatim-env))
 
 ;;;; Verse Block
 
-- 
1.8.2.1


[-- Attachment #3: Type: text/plain, Size: 46 bytes --]


-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-04-15  5:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-14 17:48 [patch] ox-latex.el to allow customization of verbatim environments (e.g., to use fancyvrb) Eric Schulte
2013-04-14 19:26 ` Nicolas Goaziou
2013-04-14 23:25   ` Bastien
2013-04-15  0:07     ` Thomas S. Dye
2013-04-15  0:25     ` Eric Schulte
2013-04-15  5:40       ` Nicolas Goaziou
2013-04-14 20:02 ` Daimrod

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).