Consider the following example:
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\lstset{language=R,
morecomment=[l]{>},
commentstyle=\color{blue},
alsoletter={*}
}
\begin{document}
\begin{lstlisting}
> q_A=0:6
> q_B=6-q_A
> N_A=6
> N_B=4
> (factorial(q_A+N_A-1)/(factorial(q_A)*factorial(N_A-1)))
[1] 1 6 21 56 126 252 462
\end{lstlisting}
\end{document}
The above code compiles to a simplified version of the image below (from the main document):
When compiling this, the asterisk *
, the underscore _
, and the slash /
are all still treated as special characters that should not be highlighted. I've already included the alsoletter
key to include e.g. *
, but the key seems to be ignored. How can I get the entire line starting with a >
to be blue?
I've already checked e.g. How can I get identifier style to apply to '%' (in a Perl listing)? for special identifiers, but that doesn't seem to work here. Neither does the "normal" approach of simply using alsoletter=*
or alsoletter={/}
, etc.
Where is it going wrong?