Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using special characters as keywords in latex listings package

I am using the listings package for latex. I am using the SQL language definition and am adding some new keywords that I need, using morekeywords=.

I have trouble defining some special characters as keywords, for example, I need [], <>, &, and -> to be considered as keywords and use the keyword style.

I have tried adding these verbatim or with a preceding backslash.
It did not work.

Your help would be greatly appreciated.

Thanks.

like image 512
sha Avatar asked Jun 09 '10 01:06

sha


1 Answers

Try making those characters to normal letters via alsoletter={yourcharacters}. Later you can specify the special characters as keywords inside morekeywords.

Here is some code:

\lstset{
...
alsoletter={.},
...
}

\begin{lstlisting}[morekeywords={this.is.a.string.with.dots}]
like image 68
ablaeul Avatar answered Sep 19 '22 04:09

ablaeul