How can I add another color at other keywords?
For example:
morekeywordsA={RequirePackage,ProvidesPackage}=\definecolor{keywordsA}{HTML}{8A4A0B}
morekeywordsB={{,},=}=\definecolor{keywordsB}{HTML}{othercolor}
\documentclass{scrreprt}
\usepackage{listings}
\usepackage[dvipsnames]{xcolor}
\definecolor{keywords}{HTML}{8A4A0B}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{comments}{HTML}{868686}
\lstset{language=[LaTeX]Tex,
keywordstyle=\color{keywords},
basicstyle=\normalfont\ttfamily,
commentstyle=\color{comments}\ttfamily,
stringstyle=\rmfamily,
numbers=left,
numberstyle=\scriptsize,
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
frameround=ftff,
frame=lines,
morekeywords={RequirePackage,ProvidesPackage},
backgroundcolor=\color{background}
}
\begin{document}
\begin{lstlisting}[firstnumber=1]
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{arsclassica}[2012/02/21 v4.0 Customizing ClassicThesis (LP)]
\RequirePackage{classicthesis}
\RequirePackage{caption}% Caption package
\end{lstlisting}
\end{document}
Best Answer
Since you want to customize (La)TeX, it's a good idea to set
texcsstyle
to have the same color as the keywords and to use the star so that the backslash will also have the same color; regarding your issue, the braces are not really keywords; I set their style (and also for the square brackets) usingliterate
(notice the*
character in the first literate line to prevent color form appearing in comments and strings):To answer your specific question, you can use
[<number>]
both inkeywordstyle
and inkeywords
, to define different keyword sets with their own style; a little exampleTo apply color to lengths, one can escape to LaTeX (this however won't work for in-line listings):