Peter Flynn
2024-02-28 00:58:44 UTC
Using the listings package. I am curious as to why the LaTeX language
has to be loaded and used as [LaTeX]TeX, but a language or dialect I
define myself can be both loaded and used by simple name alone.
===================================================================
\documentclass{article}
\usepackage{listings}
\lstdefinelanguage{DocBook}[]{XML}{morekeywords={chapter,para}}
\lstdefinelanguage{LaTeXe}[LaTeX]{TeX}{morekeywords={DeclareLanguageMapping}}
\lstloadlanguages{DocBook,[LaTeX]TeX,LaTeXe}
\begin{document}
\begin{lstlisting}[language={[LaTeX]TeX}]
\tableofcontents
\end{lstlisting}
\begin{lstlisting}[language=DocBook]
<chapter><para>
\end{lstlisting}
\begin{lstlisting}[language=LaTeXe]
\DeclareLanguageMapping
\end{lstlisting}
\end{document}
===================================================================
Peter
has to be loaded and used as [LaTeX]TeX, but a language or dialect I
define myself can be both loaded and used by simple name alone.
===================================================================
\documentclass{article}
\usepackage{listings}
\lstdefinelanguage{DocBook}[]{XML}{morekeywords={chapter,para}}
\lstdefinelanguage{LaTeXe}[LaTeX]{TeX}{morekeywords={DeclareLanguageMapping}}
\lstloadlanguages{DocBook,[LaTeX]TeX,LaTeXe}
\begin{document}
\begin{lstlisting}[language={[LaTeX]TeX}]
\tableofcontents
\end{lstlisting}
\begin{lstlisting}[language=DocBook]
<chapter><para>
\end{lstlisting}
\begin{lstlisting}[language=LaTeXe]
\DeclareLanguageMapping
\end{lstlisting}
\end{document}
===================================================================
Peter