[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [patch] ox-latex.el to allow customization of verbatim environments
From: |
Eric Schulte |
Subject: |
[O] [patch] ox-latex.el to allow customization of verbatim environments (e.g., to use fancyvrb) |
Date: |
Sun, 14 Apr 2013 11:48:08 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Please see the attached patch, I'd love for this to be applied.
Cheers,
>From 04358f2eecf99e43f79956f0d3bc66aa0ab4b95d Mon Sep 17 00:00:00 2001
From: Eric Schulte <address@hidden>
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)
;;; 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
--
Eric Schulte
http://cs.unm.edu/~eschulte