Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

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]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.