From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: [RFC] [PATCH] ox-latex: support :float no with caption for minted listings Date: Fri, 19 Sep 2014 15:04:14 -0400 Message-ID: <87mw9vqvo1.fsf@gmail.com> References: <1408779394-11436-1-git-send-email-aaronecay@gmail.com> <87ha13dm3v.fsf@nicolasgoaziou.fr> <87oavbostg.fsf@gmail.com> <87a96uep52.fsf@nicolasgoaziou.fr> <87d2bqpvgr.fsf@gmail.com> <87tx514qaa.fsf@nicolasgoaziou.fr> <87r401tdc7.fsf@gmail.com> <87oav5eztu.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV3Tp-00066h-D3 for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 15:04:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XV3Tj-0008RQ-Ar for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 15:04:29 -0400 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:59712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV3Tj-0008Q0-3e for emacs-orgmode@gnu.org; Fri, 19 Sep 2014 15:04:23 -0400 Received: by mail-qg0-f50.google.com with SMTP id q107so359804qgd.9 for ; Fri, 19 Sep 2014 12:04:17 -0700 (PDT) In-Reply-To: <87oav5eztu.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nicolas Goaziou , emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Nicolas, 2014ko abuztuak 28an, Nicolas Goaziou-ek idatzi zuen: >=20 > Hello, >=20 > Aaron Ecay writes: >=20 >> The other application I can think of is to allow captioned images and >> tables not to float. The LaTeX world is full of tutorials on how to >> un-float floating images and tables, but IME the org community doesn=E2= =80=99t >> ask for this. (perhaps they implement their own solutions in latex.) >>=20 >> Given that the capt-of package is just two lines of code, defines just >> one new command, and doesn=E2=80=99t modify any existing code, I=E2=80= =99m inclined to >> the belief that adding it to the default packages list is tolerable. >> If capt-of is added to the default packages, then > org-latex-listing =3D nil> source blocks can also be handled.=20=20 >=20 > I agree. Do you want to take care of this? This requires an entry in > ORG-NEWS and some documentation changes too. See the attached patch. I updated ORG-NEWS, but the manual (info "(org) LaTeX specific attributes") is already sufficiently general IMO. Thanks, --=20 Aaron Ecay --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-ox-latex-support-float-nil-with-caption-for-minted-l.patch Content-Transfer-Encoding: quoted-printable >From 15ced3a12b8882292f43eb7351988be4ddf3d63f Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Sat, 23 Aug 2014 03:16:11 -0400 Subject: [PATCH] ox-latex: support :float nil with caption for minted listi= ngs MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * 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 =E2=80=9Ccapt-of=E2= =80=9D package. This takes advantage of the capt-of package=E2=80=99s \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=E2=80=99t be larger than a page, generally speaking.) The listings package handles this case using its own mechanism. --- etc/ORG-NEWS | 11 +++++++---- lisp/org.el | 2 ++ lisp/ox-latex.el | 18 +++++++++++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 62181cb..08f813b 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -84,6 +84,9 @@ parameters are now supported: ~:raw~, ~:backend~. Moreov= er, 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 =3D#+attr_latex: :float nil=3D in conjunctio= n 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 =3D///=3D in addition to =3D/=3D. E= .g., @@ -137,7 +140,7 @@ So you need to replace =20 : #+HTML_INCLUDE_STYLE: t =20 -by=20 +by =20 : #+OPTIONS: :html-include-style t =20 @@ -191,13 +194,13 @@ of the list. now use =3Damssymb=3D symbols by default instead. =20 *** New functions for paragraph motion -=20=20=20=20 + The commands =3DC-down=3D and =3DC-up=3D now invoke special commands that use knowledge from the org-elements parser to move the cursor in a paragraph-like way. =20 *** New entities in =3Dorg-entities.el=3D -=20=20=20=20 + Add support for ell, imath, jmath, varphi, varpi, aleph, gimel, beth, dalet, cdots, S (=C2=A7), dag, ddag, colon, therefore, because, triangleq, leq, geq, lessgtr, lesseqgtr, ll, lll, gg, ggg, prec, preceq, @@ -305,7 +308,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. -=20=20 + When in doubt, run =3DM-x org-version RET=3D and see if you have a mixed-up installation. =20 diff --git a/lisp/org.el b/lisp/org.el index cd57ec7..1f023be 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=3D1000") "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 on `:float nil' source blocks - hyperref: for cross references =20 Therefore you should not modify this variable unless you know diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index f59d6b2..5d0a31c 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -725,6 +725,18 @@ using customize, or with \(require 'ox-latex) \(add-to-list 'org-latex-packages-alist '(\"\" \"minted\")) =20 +You can have listings with a caption which nonetheless do not +float. This is useful in case the source code takes up more than +a page, in which case trying to float it will also truncate it. +To achieve this, you should specifying the following attributes +on the source block: + + #+caption: ... + #+attr_latex: :float no + #+begin_src + ... + #+end_src + In addition, 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 @@ -2300,7 +2312,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=3D "multicolumn" float) (format "\\begin{listing*}\n%%s\n%s\\end{listing*}" caption-str)) --=20 2.1.0 --=-=-=--