3

Emacs is exporting listings blocks (i.e. #+BEGIN_SRC <lang>) in a strange, incorrect way. Here's an example of what I mean with a simple org file:

#+AUTHOR: 
#+BEGIN_SRC js
var dog = "dog!"
#+END_SRC

#+BEGIN_SRC R 
dog <- "dog!"
#+END_SRC

Here is the output LaTeX:

% Created 2014-12-15
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{color}
\tolerance=1000
\date{\today}
\title{test}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 24.3.1 (Org mode 8.2.7c)}}
\begin{document}

\maketitle
\tableofcontents

\lstset{backgroundcolor=gray,language=js
var,label= ,caption= ,numbers=none}
\begin{lstlisting}
var dog = "dog!"
\end{lstlisting}

\lstset{backgroundcolor=gray,language=R
dog,label= ,caption= ,numbers=none}
\begin{lstlisting}
dog <- "dog!"
\end{lstlisting}
% Emacs 24.3.1 (Org mode 8.2.7c)
\end{document}

The \lstset lines are messed up: they have an extra new line, and they repeat the first word given after language.

Here are the relevant lines from the (custom-set-variables section of my dotfile:

 '(org-latex-listings t)
 '(org-latex-listings-langs (quote ((emacs-lisp "Lisp") (lisp "Lisp") (clojure "Lisp") (c "C") (cc "C++") (fortran "fortran") (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby") (html "HTML") (xml "XML") (tex "TeX") (latex "[LaTeX]TeX") (shell-script "bash") (gnuplot "Gnuplot") (ocaml "Caml") (caml "Caml") (sql "SQL") (sqlite "sql") (R-mode "R"))))

 '(org-export-latex-listings t)
 '(org-export-latex-listings-langs (quote ((emacs-lisp "Lisp") (lisp "Lisp") (clojure "Lisp") (c "C") (cc "C++") (fortran "fortran") (perl "Perl") (cperl "Perl") (python "Python") (ruby "Ruby") (html "HTML") (xml "XML") (tex "TeX") (latex "TeX") (shell-script "bash") (gnuplot "Gnuplot") (ocaml "Caml") (caml "Caml") (sql "SQL") (sqlite "sql") (R-mode "R"))))

This also seems to occur if the above listings options are removed and org-export-latex-listings is set to minted:

pdfcreator={Emacs 24.3.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle
\tableofcontents

\begin{minted}[]{js
var}
var dog = "dog!"
\end{minted}

\begin{minted}[]{r
dog}
dog <- "dog!"
\end{minted}
% Emacs 24.3.1 (Org mode 8.2.10)
\end{document}
  • 1
    I cannot reproduce this, so most likely your Emacs configuration is to blame. Try exporting the same document to LaTeX in emacs -Q (after setting org-latex-listings to t) and see if the result is different. (It works for me with Org 8.2.10 and Emacs 24.4.1.) If it does work, try bisecting your init file as described elsewhere on this site. – Constantine Dec 16 '14 at 2:15
  • Bisecting my init file! That'll at least cut it to O(log(n))! – bright-star Dec 16 '14 at 10:31
3

I solved by upgrading to 24.4 and building from source. Upgrading Org alone was not enough.

I also noted that the problem went away when downgrading to the built-in Org for 24, which was 7.9.3, but that version is too low to work with now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.