6

Subsection 4.18 of the current listings documentation (2013/08/26 Version 1.5b) describes a key called tag. That key is used in lstdrvrs.dtx, which is a file that ships with listings and takes care of predefining languages. More specifically, the tag key is used in the definition of the HTML and XML languages , as follows:

\lst@definelanguage{<languagename>}{
  % ...
  tag=**[s]<>,%
  % ...
}

Why, then, can't I use the tag key in the definition of a custom language? For instance, the code below throws the following error:

!Package keyval Error: tag undefined.

My TeX distribution is up-to-date. I don't understand...

\documentclass{article}

\usepackage{listings}
\lstdefinelanguage{mylang}%
{%
    tag=**[s]<>,
}

\begin{document}
\begin{lstlisting}[language=mylang]
<b>foobar</b>
\end{lstlisting}
\end{document}
0

1 Answer 1

10

The documentation neglects to mention that the tag key is defined (in lstmisc.sty) only within the html "aspect" (not language). Loading this aspect with

\lstloadaspects{html}

(or as package option) will place the tag key at your disposal. You could also load it in the last optional argument of \lstdefinelanguage:

\lstdefinelanguage{mylang}{tag=**[s]<>}[html]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .