0

Emacs org-mode source-code blocks (between #+begin_src conf and #+end_src) support the conf "language"/style with syntax highlighting, but this is not supported when exporting to LaTeX/pdf, which uses the minted LaTeX package. Instead, LaTeX/minted gives nice results when using the aconf style, which doesn't look nice in org-mode itself.

Apart from filing a feature request, is there a quick fix/workaround where the conf style in org-mode is exported as aconf in LaTeX, or where the aconf style in org-mode gets the same status as the conf style? Or is there perhaps another solution?

1 Answer 1

1

Try customizing org-latex-minted-langs. This variable maps symbols (e.g. the symbol conf as used in your source block) to a minted "language" (e.g. the string "aconf").

The doc string of the variable (C-h v org-latex-minted-langs) says:

Alist mapping languages to their minted language counterpart. The key is a symbol, the major mode symbol without the "-mode". The value is the string that should be inserted as the language parameter for the minted package. If the mode name and the listings name are the same, the language does not need an entry in this list - but it does not hurt if it is present.

Note that minted uses all lower case for language identifiers, and that the full list of language identifiers can be obtained with:

pygmentize -L lexers

The doc string also conveniently provides a Customize link. Click on that and add an entry by clicking on the INS button at the end and entering conf as the major mode and aconf as the minted language. Click on Apply at the top and try it out. If it works, click on Apply and Save and you are done.

4
  • 1
    Great, that does exactly what I wanted. The same can be achieved by adding (add-to-list 'org-latex-minted-langs '(conf "aconf")) to init.el or .emacs.
    – AstroFloyd
    Nov 24, 2021 at 19:48
  • Indeed - this is a simple case, so you don't need the Customize interface (but that is definitely not always the case, so using it by default is the safer option).
    – NickD
    Nov 24, 2021 at 20:12
  • True, but this way the new option is added to the default ones, rather than overwriting the default with itself plus the new option. If the default changes, the new values would be lost. BTW, I noticed that in my orgmode version (9.5) the variable is called org-latex-minted-langs rather than org-latex-minted-languages.
    – AstroFloyd
    Nov 24, 2021 at 20:23
  • 1
    It is indeed org-latex-minted-langs: fixed - thanks!
    – NickD
    Nov 24, 2021 at 23:19

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.