emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rick Frankel <rick@rickster.com>
To: emacs-orgmode@gnu.org
Subject: new latex exporter
Date: Fri, 15 Mar 2013 13:59:00 -0400	[thread overview]
Message-ID: <7B54CD4D-8BD5-4676-9B81-DBEE275B20C2@rickster.com> (raw)

There is a problem (bug?) with ox-latex and long listings. If the
listing has a label (name) or caption, it is wrapped in a
'\begin{listing}[H]' block even when the org-latex-listings type is
set to 'minted. This causes listings longer than one page to be
truncated if they have labels, which means you can't have callable
code longer than one page (~40 lines for US Letter paper.)

An example document (with a proposed solution) is below.

---
#+TITLE:    Test
#+OPTIONS:  H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:{} -:t f:t *:t <:t

* Setup and short examples
:PROPERTIES:
:EXPORTS:  code
:END:
*NOTE:* Run this section to generate the long examples before
generating the latex/pdf output.
** latex listing options
#+BEGIN_SRC elisp :results silent
  (setq
  org-latex-listings 'minted
  org-latex-minted-options
  '(("linenos" "true") ("stepnumber" "5") ("numbersep" "0.25em")
    ("frame" "leftline") ("framerule" "1pt")
    ("rulecolor" "\\color{framecolor}")))
#+END_SRC

** patch
#+BEGIN_SRC diff :eval never
  diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
  index 8a24aea..388eb2e 100644
  --- a/lisp/ox-latex.el
  +++ b/lisp/ox-latex.el
  @@ -2160,7 +2160,7 @@ contextual information."
          ;; Case 3.  Use minted package.
          ((eq org-latex-listings 'minted)
      (let ((float-env
  -          (when (or label caption)
  +          (when caption
          (format "\\begin{listing}[H]\n%%s\n%s\\end{listing}"
              (org-latex--caption/label-string src-block info))))
            (body
#+END_SRC
** source w/ no label
#+BEGIN_SRC perl :eval never
  foreach my  $i qw(with without) {
      print join(
          "\n",
          sprintf("* Long listing %s label", $i),
          ($i eq 'with' ? '#+name: long-listing' : ''),
          "#+BEGIN_SRC perl :exports code",
          (map { "print '$_'" } 1..60),
          "#+END_SRC\n",
      );
  }
#+END_SRC
** src w/ with label
#+name: generate-listing
#+BEGIN_SRC perl :results raw
  foreach my  $i qw(with without) {
      print join(
          "\n",
          sprintf("* Long listing %s label", $i),
          ($i eq 'with' ? '#+name: long-listing' : ''),
          "#+BEGIN_SRC perl :exports code",
          (map { "print '$_'" } 1..60),
          "#+END_SRC\n",
      );
  }
#+END_SRC

#+RESULTS: generate-listing

                 reply	other threads:[~2013-03-15 17:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=7B54CD4D-8BD5-4676-9B81-DBEE275B20C2@rickster.com \
    --to=rick@rickster.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).