When I export an Emacs OrgMode buffer like:

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

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

  pdfcreator={Emacs 24.5.1 (Org mode 8.2.10)}}


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

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 ?

2 Answers 2


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. Commented Nov 6, 2017 at 20:39
  • I have Emacs 25.3.2 (Org mode 9.1.2), maybe you could consider to upgrade.
    – rvf0068
    Commented Nov 6, 2017 at 22:40
  • 1
    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! Commented Nov 7, 2017 at 7:10

For numbered listings specifically, you'll need to add "-n" to your source block's header:

#+begin_src sh -n
echo "hello world"

Exports as:

1 echo "hello world"

  • This does work for me. I had been trying to include line numbers for my source code blocks in my Org mode's exports to LaTex, and then to PDF.
    – Punit Arya
    Commented Oct 19, 2023 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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