I'm trying to add different styles (color, etc.) to different groups of words in the listings
package. Note that my question is different from How can I use multiple declarations (\textbf, \emph) in listings' emphstyle?.
Let me show you some code:
\documentclass{article}
\usepackage{listings}
\begin{document}
...
\begin{lstlisting}
{
"id": {integer},
"login": {string},
"password": {string},
"name": {string},
"picture": {
File Resource
}
}
...
PUT /files/{file_id}
\end{lstlisting}
\end{document}
I use the \lstset
command to define the following:
...
emph={ % HTTP Request
GET,POST,PUT,DELETE
},
emphstyle={\color{green}},
...
but I would like to add more words with a different style (color, etc.), like so
...
emph2={ % Variable Types
integer,string,blob,datetime
},
emphstyle2={\color{darkBlue}},
...
How can I do that?
Best Answer
You're halfway there. The
listings
manual (p.31 in v1.5b) tells you that multiple classes of identifiers and associated styles can be defined by usingwhere
<number>
is some integer of your choice that gets associated with the class of identifiers in question.