Question

I'm using the listings package for syntax highlighting, set up with the following arguments:

\lstset{
  language=Java,
  captionpos=b,
  tabsize=3,
  frame=lines,
  numbers=left,
  numberstyle=\tiny,
  numbersep=5pt,
  breaklines=true,
  showstringspaces=false,
  basicstyle=\footnotesize,
  identifierstyle=\color{magenta},
  keywordstyle=\bfseries,
  commentstyle=\color{darkgreen},
  stringstyle=\color{red}
}

This works fairly well, resulting in:

(screenshot 1 of resulting document) (screenshot 2 of resulting document)

What I would like, is that the constants MIN_PIXELS and MAX_PROCESSING_TIME are styled in a different color, and the class names Rectangle, Bitmap, etc. are styled in yet another color. It would also be nice if I could get numbers colored, but that's not my main focus.

Is there any way to do this?

Was it helpful?

Solution

From documentation of listings (page 20ff.): \lstset{morecomment=[s][\color{blue}]{/*+}{*/}, morecomment=[s][\color{red}]{/*-}{*/}} You can try to set morekeywords and give a specific keyword the right color.

OTHER TIPS

Listings only works by keywords, so it is not possible.

Minted uses a python library (Pygments) and can do any kind of highlighting as it is able to understand the code and not just keywords.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top