Am 28.02.2024 um 01:58 schrieb Peter Flynn:
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.
Maybe I don't get your point, but I want to share my thoughts on that
issue. Let me add that I'm not an expert with listings.
As far as I understand the manual there are single languages and
languages with one or more dialects. In the former case you can load the language by using its name. For languages with dialects you need to
specify which dialect you want to use. But it is possible to define a
default dialect for a language. In that case you can load the language
with that dialect by simply using the language name. According to the
manual for TeX the default dialect is plain. So just loading TeX as
language would invoke plain TeX.
In your example below you define a new language called LaTeXe based on [LaTeX]{TeX}. Now LaTeXe is a language without dialects and can be
loaded without specifying one.
If I understand you correctly you would like to load [LaTeX]{TeX} by
just specifying LaTeX. Which doesn't work.
Now I tried something which presumably doesn't make sense, but it works.
\lstdefinelanguage[Peter]{MyHTML}[]{HTML}{...} \lstdefinelanguage[Peter]{MyXML}[]{XML}{...}
You can define several languages with the same dialect name. So
specifying just the dialect is not distinct.
%%%%%
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor} \lstdefinelanguage[Peter]{MyHTML}[]{HTML}{morekeywords={Peter}} \lstdefinelanguage[Peter]{MyXML}[]{XML}{morekeywords={Peter}}
\begin{document}
\begin{lstlisting}[language={[Peter]{MyHTML}}]
Hallo Peter
\end{lstlisting}
\begin{lstlisting}[language={[Peter]{MyXML}}]
Hallo Peter
\end{lstlisting}
\end{document}
%%%%%
I hope this helps a bit.
Holger
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)