emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] new latex exporter


From: Rick Frankel
Subject: [O] new latex exporter
Date: Fri, 15 Mar 2013 13:59:00 -0400

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 via email to

[Prev in Thread] Current Thread [Next in Thread]