How can I get the language currently set for the listings (aka lstlistings
) package, e.g. via \lstset{language=Python,basicstyle=\color{blue},backgroundcolor=\color{lightgray}}
?
Details:
I want to use the value in my own command that also puts some lstinline
text into the index, under the right language.
I tried variables like \language
, \lst.language
, ... But they do not contain the value.
Hence I introduced a new variable via e.g. \newcommand{\lstLanguage}{Python}
in each chapter, and used \lstset{language=\lstLanguage,basicstyle=\color{blue},backgroundcolor=\color{lightgray}}
instead. But that causes the error
! Package Listings Error: language Python undefined