I'm currently using the listings
package to render my XML snippets. The default XML language settings recognize elements, attribute and text properly and my style is set to render tag names bold, however, I'd like to see the tag surrounding brackets in a bold font face.
So by default a tag is rendered like this: <html> but I'd like it like <.html> (I had to add the . to fool the syntax highlighting). Do you have any ideas how to do that?
I know I could use minted
, but I have long snippets than run over more than one page and I also need line wrapping which is AFAIK not supported by minted
.
Best Answer
As per Mico's answer to using bold italic text inside listings, there is no boldfaced mono spaced font in the Computer Modern font family, so you need to use a font that has a bold mono spaced font.
Borrowing from this earlier question on XML syntax highlighting, here is an example:
Known Issues:
I am not sure why the very first non-comment
<
was not being highlighted.Matthias's suggested that this behavior can be overcome by using an
escapechar
and replacing the first<
with!\color{red}{<}!
where!
is theescapechar
. This has been incorporated into the solution below.Code:
Alternate Solution:
Using the solution form ttfamily with bfseries or how to enable bold in fixed width font you can use the courier font with
but I personally find these results no so satisfying:
Code:
Same as above but delete
\usepackage{pxfonts}
and add: