[Tex/LaTex] How to avoid the use of default styles when no listings language is set


When global listings styles have been defined identifiers are coloured differently from numbers even if no language is in effect. How can this be avoided?

123 hello world 456

enter image description here

Best Answer

As @jubobs commented, Listings treats language and style separately.

  • By defining a language, you tell Listings how it should analyze the code; such as "string in quotation marks" and //comment after double slashes.
  • By defining a style, you tell Listings how it should typeset the code; such as "strings goes italic" and //comments shrinks.

Go back to your question, a stylish setting is permanent unless you issue another stylish setting or the current group terminates. Similarly, a language assignment is permanent unless you assign another language, the current group terminates, or you issue a stylish setting that contains a language assignment.

In conclusion, perhaps the most systematic way to manage both language and style is to define an exhaustive style that contains a language assignment together with its associated stylish setting. (Just like a language-IDE pair.) And now you can switch between IDEs styles and the no-style-at-all style.


\lstdefinestyle{my IDE setting}{

\lstset{style=my IDE setting}
\lstinline{123 hello world 456}

\lstinline{123 hello world 456}

Related Question