General ⇒ Workaround for syntax highlighting after $ in verbatim?
-
- Posts: 5
- Joined: Thu Sep 12, 2013 8:01 am
Workaround for syntax highlighting after $ in verbatim?
I'm writing something with a code listing inside verbatim, and that uses a $ inside of it. It's unpaired, so the syntax highlighting shows green for the rest of the document. This has actually been reported as a bug http://sourceforge.net/p/texniccenter/bugs/318/, but it's still open 2.5 years later. Does anyone know of a workaround for this until it gets fixed?
Thanks
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Re: Workaround for syntax highlighting after $ in verbatim?
-
- Posts: 5
- Joined: Thu Sep 12, 2013 8:01 am
Re: Workaround for syntax highlighting after $ in verbatim?
Interestingly, I still have TexnicCenter 1.0 installed on my laptop, and the issue does not exist there.
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Workaround for syntax highlighting after $ in verbatim?
EDIT: Well, that won't work obviously.

But try this:
Code: Select all
\documentclass{article}\usepackage{listings}\def\dollar{\$}\lstset{literate={4>}{\$}1}\begin{document}\dollar\begin{lstlisting}\dollar\$4>\end{lstlisting}\end{document}
4>
is replaced with a dollar dign in the output. You might want to use something else, something easy to remember for you. now that i think about it, how about §
?-
- Posts: 5
- Joined: Thu Sep 12, 2013 8:01 am
Re: Workaround for syntax highlighting after $ in verbatim?
Any chance of a fix for this?
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm