# OrgMode, how to pass options to LaTex listings?

When I export an Emacs OrgMode buffer like:

#+LATEX_HEADER: \usepackage{listings}
* How to pass options to LaTex listings?
#+ATTR_LATEX: :options [numbers=left]
#+BEGIN_SRC sh
echo "hello world"
#+END_SRC


the exported LaTex buffer does not contain the numbers=left but the default numbers=none.

...snip
\usepackage{listings}
\date{\today}
\title{demo-listings-2}
\hypersetup{
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 24.5.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle
\tableofcontents

\section{How to pass options to LaTex listings?}
\label{sec-1}
\lstset{language=sh,label= ,caption= ,numbers=none}
\begin{lstlisting}
echo "hello world"
\end{lstlisting}
% Emacs 24.5.1 (Org mode 8.2.10)
\end{document}


I expected the ATTR_LATEX: :options [numbers=left] to override the default value.

The only LaTex configuration I have in the .emacsfile is:

(require 'ox-latex)
(setq org-latex-listings t)


Any idea of what I am missing or doing wrong ?

You have to use #+ATTR_LATEX: :options numbers=left (without the []). More options can be separated by commas: :options numbers=left, captionpos=b.

• Thanks for taking the time to answer. I tried your suggestion, but the result is the same. I am not able to override the default value. – Morten Banzon Nov 6 '17 at 20:39
• I have Emacs 25.3.2 (Org mode 9.1.2), maybe you could consider to upgrade. – rvf0068 Nov 6 '17 at 22:40
• Thanks again! I tried with a default Ubuntu 17.10 distro, {Emacs 25.2.2 (Org mode 8.2.10)}} and got the same results. I upgraded the Org mode to {Emacs 25.2.2 (Org mode 9.1.2)} and now it works. Thanks for the help! – Morten Banzon Nov 7 '17 at 7:10

#+begin_src sh -n

1 echo "hello world"