summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ecay <aaronecay@gmail.com>2014-08-23 03:16:11 -0400
committerAaron Ecay <aaronecay@gmail.com>2014-09-22 22:46:26 -0400
commit200eeb572318a3b8c02beb2e35e7df025d02dfea (patch)
tree0a7959516d80728e5d52b2d41ee23d57cb436af2
parenta24ac01cd53646fa0f622b998cdbddf8787a1713 (diff)
downloadorg-mode-200eeb572318a3b8c02beb2e35e7df025d02dfea.tar.gz
ox-latex: support :float nil with caption for minted listings
* lisp/ox-latex.el (org-latex-src-block): Support :float nil with caption for minted. (org-latex-listings): Edit docstring to describe this usecase. * lisp/org.el (org-latex-default-packages-alist): Add “capt-of” package. This takes advantage of the capt-of package’s \captionof command, which allows to insert a caption (with autogenerated number and \ref-able label) without creating a floating environment. One example of where this is useful is in the case of a minted source code listing that spans more than one page. (Latex floats can’t be larger than a page, generally speaking.) The listings package already handles this case using its own mechanism.
-rw-r--r--etc/ORG-NEWS11
-rwxr-xr-xlisp/org.el2
-rw-r--r--lisp/ox-latex.el6
3 files changed, 14 insertions, 5 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 8a5b8c1..1af54ad 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -87,6 +87,9 @@ parameters are now supported: ~:raw~, ~:backend~. Moreover, there are
new parameters specific to some pre-defined translators, e.g.,
~:environment~ and ~:booktabs~ for ~orgtbl-to-latex~. See translators
docstrings (including ~orgtbl-to-generic~) for details.
+*** Non-floating minted listings in Latex export
+It is not possible to specify =#+attr_latex: :float nil= in conjunction with
+source blocks exported by the minted package.
** Miscellaneous
*** File names in links accept are now compatible with URI syntax
Absolute file names can now start with =///= in addition to =/=. E.g.,
@@ -140,7 +143,7 @@ So you need to replace
: #+HTML_INCLUDE_STYLE: t
-by
+by
: #+OPTIONS: :html-include-style t
@@ -194,13 +197,13 @@ of the list.
now use =amssymb= symbols by default instead.
*** New functions for paragraph motion
-
+
The commands =C-down= and =C-up= now invoke special commands
that use knowledge from the org-elements parser to move the cursor
in a paragraph-like way.
*** New entities in =org-entities.el=
-
+
Add support for ell, imath, jmath, varphi, varpi, aleph, gimel, beth,
dalet, cdots, S (§), dag, ddag, colon, therefore, because, triangleq,
leq, geq, lessgtr, lesseqgtr, ll, lll, gg, ggg, prec, preceq,
@@ -308,7 +311,7 @@ instructions:
- when updating through ELPA (either from GNU ELPA or from Org ELPA),
you have to install Org's ELPA package in a session where no Org
function has been called already.
-
+
When in doubt, run =M-x org-version RET= and see if you have a mixed-up
installation.
diff --git a/lisp/org.el b/lisp/org.el
index 4ffe1e8..b09e72d 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4000,6 +4000,7 @@ header, or they will be appended."
("" "marvosym" t)
("" "wasysym" t)
("" "amssymb" t)
+ ("" "capt-of" nil)
("" "hyperref" nil)
"\\tolerance=1000")
"Alist of default packages to be inserted in the header.
@@ -4021,6 +4022,7 @@ Org mode to function properly:
- textcomp, marvosymb, wasysym, amssymb: for various symbols used
for interpreting the entities in `org-entities'. You can skip
some of these packages if you don't use any of their symbols.
+- capt-of: for captions outside of floats
- hyperref: for cross references
Therefore you should not modify this variable unless you know
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 218c69f..08f7f1c 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2301,7 +2301,11 @@ contextual information."
((eq listings 'minted)
(let* ((caption-str (org-latex--caption/label-string src-block info))
(float-env
- (cond ((and (not float) (plist-member attributes :float)) "%s")
+ (cond ((and (not float) (plist-member attributes :float) caption)
+ (format "%%s\n%s" (replace-regexp-in-string
+ "\\\\caption" "\\captionof{listing}"
+ caption-str t t)))
+ ((and (not float) (plist-member attributes :float)) "%s")
((string= "multicolumn" float)
(format "\\begin{listing*}\n%%s\n%s\\end{listing*}"
caption-str))