From af8a3032884e536aa4a398d3c248cb76b689b977 Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda Gutierrez" Date: Wed, 14 Dec 2022 07:22:23 +0100 Subject: [PATCH 2/3] lisp/ox-latex.el: Add org-latex-listings-src-omit-language * lisp/ox-latex.el: Add org-latex-listings-src-omit-language variable to control whether language= should be included in the parameters of the lstlisting environmet generated by a SRC block. --- lisp/ox-latex.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index f03903605..f18c2a068 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1021,6 +1021,24 @@ in this list - but it does not hurt if it is present." (symbol :tag "Major mode ") (string :tag "Listings language")))) +(defcustom org-latex-listings-src-omit-language nil + "Set this option to t to omit the +\"language=\" +in the parameters to \\begin{lstlisting} when exporting a src block. + +This is necessary, for example, when the `fancyvrb' package is used +instead of `listings' by including the following in the doc header: + +#+LATEX_HEADER: \\RequirePackage{fancyvrb} +#+LATEX_HEADER: \\DefineVerbatimEnvironment{verbatim}{Verbatim}{...} +#+LATEX_HEADER: \\DefineVerbatimEnvironment{lstlisting}{Verbatim}{...} + +{...} is whatever default parameters you need to pass to either environment. +" + :group 'org-export-latex + :package-version '(Org . "9.7") + :type 'boolean) + (defcustom org-latex-listings-options nil "Association list of options for the latex listings package. @@ -3593,7 +3611,8 @@ and FLOAT are extracted from SRC-BLOCK and INFO in `org-latex-src-block'." ((string= "multicolumn" float) '(("float" "*"))) ((and float (not (assoc "float" lst-opt))) `(("float" ,(plist-get info :latex-default-figure-position))))) - `(("language" ,lst-lang)) + (unless org-latex-listings-src-omit-language + `(("language" ,lst-lang))) (when label `(("label" ,(org-latex--label src-block info)))) (when caption-str -- 2.25.1