# How to emphasize within a listing two successive identifiers separated by a space?

I have this pgfplots code that I want to put in a lstlisting environment:

``````\pgfplotsset{
every axis x label/.append style = {
font = \small
},
every axis y label/.append style = {
font = \small,
rotate = -90,
xshift = 0.5em
}
}
``````

How can I convince the listings package that those strings like "every axis x label" have to be treated as identifiers? I don't like the idea of assigning the role of keyword to the single substrings "every", "axis", "x", "label".

-
Alternatively, you can use special markers for these kind of keywords, such as enclosing them within colons. For instance `:every axis x label:` and so on... Listings can highlight everything between the colons (without printing them of course). See this question. –  guillem Nov 20 '12 at 7:21

According to the `listings` package documentation this is an explicit impossibility. Quoted, from page 21 (with some emphasis):

Another problem: by default some characters are not allowed inside keywords, for example `-`, `:`, `.`, and so on. The reference guide covers this problem by introducing some more keys, which let you adjust the standard character table appropriately. But note that white space characters are prohibited inside keywords.

For small instances, there exists no viable alternative at the moment within `listings`. However, for larger or more general instances, the code examples included in the `pgf` package documentation (using the `codeexample` environment) may be of some help.

-
So, I wonder how did the authors of tikz and pgfplots achieve the pretty printing of their code with listings. –  agodemar Sep 6 '11 at 16:36
Furthermore, it seems unlikely that a small amount of TeX hacking will make it convenient to use space characters valid in keywords, because they are most often used to determine the boundaries of keywords: any keyword which was bracketed by space characters would not be recognised. –  Niel de Beaudrap Sep 6 '11 at 16:39
The automated highlighting in pgfplots and tikz is proprietary, it has been written from scratch in order to support the pgfkeys environment. These manuals do not use `listings`. In this particular context, spaces are part of keywords and the delimiters are well-defined. Unfortunately, the library which does the highlighting is not yet ready as separate package (although it is used for at least pgfmanual.pdf, pgfplots.pdf, and pgfplotstable.pdf and is general enough for more pgfkeys based approaches). –  Christian Feuersänger Sep 6 '11 at 20:29
@Christian: Only the first page of the current `pfg` manual uses `listings` to typeset the code. As such, you'll notice highlights occurring only for single-words. Does "proprietary" imply that the `pgf` documentation will not compile in the hands of the general public? –  Werner Sep 6 '11 at 20:48
@Werner the pgf manual can be compiled by anyone who wants to do so (the same holds for pgfplots). I wanted to express that the underlying highlighting routines are subroutines which have been written by me with pgfplots and pgf in mind. But so far, I only planned to provide the necessary code-cleanup and documentation to make them usable for other packages. You can use them for your package if you are willing to read the code comments and the code as such. –  Christian Feuersänger Sep 7 '11 at 17:43