I would like to force the listings
package to be more selective when highlighting keywords. I'm currently including C source files in my document, and while I'm happy that occurrences of the float keyword are properly highlighted, I'd like the following line to appear as
#include <float.h>
instead of the current
#include <
float.h>
In a similar spirit, else is fine, but #else
should be typeset instead of #else.
I tried solutions like using deletekeywords={float.}
, but to no avail (unsurprisingly, according to the documentation: "(…) by default some characters are not allowed inside
keywords, for example ‘-’, ‘:’, ‘.’, and so on. (…)"). Playing with deletedirectives
led nowhere either.
Best Answer
The keyword is
float
without dot, notfloat.
:It is more difficult to have both. The
literate
feature seems to do the trick:If you do not want a special formatting of directives, it can be disabled by an empty
directivestyle
: