Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using this code to define keywords for listings

\lstdefinestyle{demostyle}{
    columns=flexible,
    keepspaces=true,    
    basicstyle=\small\ttfamily,
    language = [LaTeX]TeX,
    morekeywords={textwidth,color,let},
}
\lstloadlanguages{[LaTeX]TeX}

However that marks every word color as a keyword, no matter if it is preceded by a \.

I however really want only LaTeX keywords to be highlighted.

Can this somehow be achieved?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

You want moretexcs, I think

\lstdefinestyle{demostyle}{
    columns    = flexible,
    keepspaces = true,    
    basicstyle = \small\ttfamily,
    language   = [LaTeX]TeX,
    moretexcs  = {textwidth,color,let},
}
share|improve this answer
    
I switched to morekeywords for some reason I can not remember. Is there a limit on the number of codewords ? Speed of compilation does not matter. –  Matthias Pospiech Jul 22 '12 at 16:50
    
@MatthiasPospiech No idea about a limit: I've certainly not found one in siunitx, where the list is pretty big. –  Joseph Wright Jul 22 '12 at 16:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.