From: Lixin Chin <lixinchin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] ox-latex.el: Wrap 'minted' src blocks in a 'listing', environment
Date: Tue, 31 Jan 2017 14:28:16 +0800 [thread overview]
Message-ID: <b7cd9382-6a1c-f788-82f8-98a481985fc8@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2674 bytes --]
Hi everyone,
Included is a patch to make the 'minted' source code syntax highlighting
package behave the same as the 'listings' source code syntax package
when exporting an org-mode document to LaTeX.
Previously, 'minted' would only get exported to a floating environment
if '#+ATTR_LATEX: :float multicolumn' was provided, whereas the
org-mode documentation implies that it should be floated if any caption
is provided.
Regards,
Lixin Chin
* lisp/ox-latex.el (org-latex-src-block): Make source highlighting
using the 'minted' syntax highlighting package behave the same as
using the 'listings' syntax highlighting package.
The source block should be floating if a caption is provided, or if
':float t' is provided in an '#+ATTR_LATEX:' block. Previously, the
source block would only be floating if ':float multicolumn' was
provided. This now matches the org-mode documentation for source
blocks.
---
lisp/ox-latex.el | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index d05991233..3cea81650 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1301,7 +1301,7 @@ For non-floats, see `org-latex--wrap-label'."
(and (eq type 'src-block)
(not (plist-get attr :float))
(memq (plist-get info :latex-listings)
- '(nil minted)))))
+ '(nil)))))
(short (org-export-get-caption element t))
(caption-from-attr-latex (plist-get attr :caption)))
(cond
@@ -2880,13 +2880,19 @@ contextual information."
(float-env
(cond
((string= "multicolumn" float)
- (format "\\begin{listing*}\n%s%%s\n%s\\end{listing*}"
+ (format "\\begin{listing*}[%s]\n%s%%s\n%s\\end{listing*}"
+ (plist-get info :latex-default-figure-position)
(if caption-above-p caption-str "")
(if caption-above-p "" caption-str)))
(caption
- (concat (if caption-above-p caption-str "")
- "%s"
- (if caption-above-p "" (concat "\n" caption-str))))
+ (format "\\begin{listing}[%s]\n%s%%s\n%s\\end{listing}"
+ (plist-get info :latex-default-figure-position)
+ (if caption-above-p caption-str "")
+ (if caption-above-p "" caption-str)))
+ ((string= "t" float)
+ (concat (format "\\begin{listing}[%s]\n"
+ (plist-get info :latex-default-figure-position))
+ "%s\n\\end{listing}"))
(t "%s")))
(options (plist-get info :latex-minted-options))
(body
--
2.11.0
[-- Attachment #2: 0001-ox-latex.el-Wrap-minted-src-blocks-in-a-listing-envi.patch --]
[-- Type: text/plain, Size: 2236 bytes --]
From 4daf10b3f5283e3e992fc9e11ff76b6b33c488b6 Mon Sep 17 00:00:00 2001
From: Lixin Chin <lixin.chin@research.uwa.edu.au>
Date: Tue, 31 Jan 2017 14:15:40 +0800
Subject: [PATCH] ox-latex.el: Wrap 'minted' src blocks in a 'listing'
environment
* lisp/ox-latex.el (org-latex-src-block): Make source highlighting
using the 'minted' syntax highlighting package behave the same as
using the 'listings' syntax highlighting package.
The source block should be floating if a caption is provided, or if
':float t' is provided in an '#+ATTR_LATEX:' block. Previously, the
source block would only be floating if ':float multicolumn' was
provided. This now matches the org-mode documentation for source
blocks.
---
lisp/ox-latex.el | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index d05991233..3cea81650 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1301,7 +1301,7 @@ For non-floats, see `org-latex--wrap-label'."
(and (eq type 'src-block)
(not (plist-get attr :float))
(memq (plist-get info :latex-listings)
- '(nil minted)))))
+ '(nil)))))
(short (org-export-get-caption element t))
(caption-from-attr-latex (plist-get attr :caption)))
(cond
@@ -2880,13 +2880,19 @@ contextual information."
(float-env
(cond
((string= "multicolumn" float)
- (format "\\begin{listing*}\n%s%%s\n%s\\end{listing*}"
+ (format "\\begin{listing*}[%s]\n%s%%s\n%s\\end{listing*}"
+ (plist-get info :latex-default-figure-position)
(if caption-above-p caption-str "")
(if caption-above-p "" caption-str)))
(caption
- (concat (if caption-above-p caption-str "")
- "%s"
- (if caption-above-p "" (concat "\n" caption-str))))
+ (format "\\begin{listing}[%s]\n%s%%s\n%s\\end{listing}"
+ (plist-get info :latex-default-figure-position)
+ (if caption-above-p caption-str "")
+ (if caption-above-p "" caption-str)))
+ ((string= "t" float)
+ (concat (format "\\begin{listing}[%s]\n"
+ (plist-get info :latex-default-figure-position))
+ "%s\n\\end{listing}"))
(t "%s")))
(options (plist-get info :latex-minted-options))
(body
--
2.11.0
next reply other threads:[~2017-01-31 6:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-31 6:28 Lixin Chin [this message]
2017-01-31 8:04 ` [PATCH] ox-latex.el: Wrap 'minted' src blocks in a 'listing', environment Nicolas Goaziou
2017-01-31 8:22 ` Lixin Chin
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=b7cd9382-6a1c-f788-82f8-98a481985fc8@gmail.com \
--to=lixinchin@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).