I want to change the exported tag of

#+begin_src python 



exports to




I want it to be export to


Anyone has any idea ?? I've only found

#+ATTR_LATEX: :environment python
#+begin_example python

but then I cant run it ....

1 Answer 1


Do C-h v org-latex-listings (or C-h v org-latex-src-block-backend as it was renamed in Org mode 9.6): you probably have it set to verbatim. Try one of the others: listings is the simplest to set up, but probably not good-looking enough; minted takes some customization (described in the doc string above) but looks pretty good - it's the one that I've used for many years; engraved is a recent addition that I have not tried yet, but I'm planning to try it soon.

If you really want a custom environment (like your python environment in the question), you can set org-latex-listings and org-latex-custom-lang-environments appropriately. Again, doing C-h v org-latex-custom-lang-environments is the indispensable first step towards enlightenment.

Here's what you would add to your init file to get that:

(with-eval-after-load 'ox-latex
   (setq org-latex-listings "listings")
   (add-to-list 'org-latex-custom-lang-environments '(python "python")))

With that, if I export this:

* Code

#+begin_src python :exports both
  print("Hello World!")

I get this:




print("Hello World!")

Of course, you will need to provide the definition of the python environment to LaTeX. I don't have a python environment defined, so I cannot process it any further.

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.