I'm using Kile
to edit my LaTeX documents. I define my own custom environment to hightlight LaTeX code named lstLaTeX
with the following code:
\documentclass[a4paper]{scrartcl}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[latin1]{inputenc}
\usepackage[ngerman,english]{babel}
\usepackage{listings}
\definecolor{lightgrey}{rgb}{0.9,0.9,0.9}
\definecolor{darkgreen}{rgb}{0,0.6,0}
\lstnewenvironment{lstLaTeX}
{
\lstset{language=[LaTeX]TeX,
keepspaces=true,
texcsstyle=*\bf\color{blue},
basicstyle=\ttfamily,
numbers=none,
breaklines=true,
keywordstyle=\color{darkgreen},
commentstyle=\color{red},
morekeywords={},
otherkeywords={$, \{, \}, \[, \]},
frame=none,
tabsize=2,
columns=fullflexible,
backgroundcolor=\color{lightgrey},
escapechar=°
}
}
{}
\begin{document}
The actual document.
Here some LaTeX code:
\begin{lstLaTeX}
Brackets should be {\bf highlighted}.
The dollar sign: $x=5$
\end{lstLaTeX}
\end{document}
The problem is that Kile cannot deal with the single dollar sign in the preamble and marks all following text green (because it thinks there should be a math environment).
I already read how to teach Kile to ignore dollar signs when used inside custom environments here: disable syntax highlighting in kile But this post doesn't solve my problem.
So it would be nice if I could tell Kile to ignore this single dollar sign. I already tried to add %$
at the end of the line with the single dollar sign but Kile ignores this.
{$, % $ <newline> \[, \], ...
. I'm not a Kile user so I can't check if it respects this. – Joseph Wright♦ Mar 30 '14 at 14:10$
and it ignores%$
. – Steven Thiel Mar 30 '14 at 20:09$
withl3regex
, but it turns all remaining content in my.cls
magenta! And obviously repetition isn't an option in this case. (I know I can use\Z
but that is much less readable for me. – cfr Jan 19 '17 at 23:09