Using listings
, I'm trying to typeset single-line comments in a very specific way: although whatever follows should be typeset according to the value passed to the commentstyle
key, the opening delimiter should be typeset in the identifier style (i.e. that of the "normal code").
I've been playing around with the different types (s
,m
,l
) and the i
prefix of morecomment
offered by the listings
package, to no avail. Any idea?
Edit: Of course, one requirement is that I shouldn't have to alter the listing itself to to obtain the desired output; introducing delimiters in the listing is cheating :)
\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstset%
{%
basicstyle=\ttfamily,
commentstyle=\itshape\color{blue},
morecomment=[s]{\%\%}{\^^M},
}
\begin{document}
\lstset{}
\begin{lstlisting}
confusion=Inf %% this is a comment
\end{lstlisting}
How can I get the opening comment delimiter (\texttt{\%\%}) to be typeset,
not in blue, but in the default colour (black)?
\end{document}