Possible Duplicate:
How to emphasize within a listing two successive identifiers separated by a space?
I am trying to highlight the following keywords with the listings package:
over window:time
over window:length
If I declare:
\lstdefinelanguage{drl}{
morekeywords=[2]{length,over,time,window},
keywordstyle=[2]\color{darkred}\bfseries
}
I get the job done, however the colon is not highlighted and I cannot use length, over, time and window as identifiers or otherwise they are highlighted as keywords (time, for example, is often used as identifier in my language since I have to deal with temporal events and operators).
So I tried the following:
\lstdefinelanguage{drl}{
alsoletter={:},
morekeywords=[2]{over,window:length,window:time},
keywordstyle=[2]\color{darkred}\bfseries
}
and now window:length and window:time are properly recognised as a single entity but still I cannot user over as an identifier. So I tried to go further on that way by declaring the following (comments represent additional unsuccessful tries):
\lstdefinelanguage{drl}{
alsoletter={ ,:},
% alsoletter={\ ,:},
% alsoletter={{ },:},
morekeywords=[2]{over window:length,over window:time},
keywordstyle=[2]\color{darkred}\bfseries
}
How are blankspaces encoded? What am I missing? What am I doing wrong? Any help is much appreciated! Below you can find a full working example if you want to play with the code:
\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\definecolor{darkred}{RGB}{151,0,11}
\lstdefinelanguage{drl}{
alsoletter={ ,:},
% alsoletter={\ ,:},
% alsoletter={{ },:},
morekeywords=[2]{over window:length,over window:time},
keywordstyle=[2]\color{darkred}\bfseries
}
\lstset{
gobble=4,
language=drl
}
\begin{document}
\begin{lstlisting}
over = 5 s;
time = 10 ms;
eval(time < over)
this over window:length( 5 )
this over window:time( 30s )
\end{lstlisting}
\end{document}
Thanks in advance!