LaTeX forum ⇒ GeneralWorkaround for syntax highlighting after $ in verbatim?

General information and discussion about TeXnicCenter
schweinhundert
Posts: 5
Joined: Thu Sep 12, 2013 8:01 am

Workaround for syntax highlighting after $ in verbatim?

Postby schweinhundert » Wed Aug 06, 2014 10:59 pm

Hi,

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

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3615
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Aug 07, 2014 9:51 am

You could outsource the listing into it's own texfile and input it back in your document. This way the highlighting is only messed up in the file containing the listing.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

schweinhundert
Posts: 5
Joined: Thu Sep 12, 2013 8:01 am

Postby schweinhundert » Thu Aug 07, 2014 8:29 pm

Hm. Okay, that could work, thanks. Unfortunately I have a bunch of these as tiny snippets, so it's going to be cumbersome.

Interestingly, I still have TexnicCenter 1.0 installed on my laptop, and the issue does not exist there.

User avatar
Johannes_B
Site Moderator
Posts: 3615
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Fri Aug 08, 2014 8:30 am

You could also hide the dollarsign in a macro.

EDIT: Well, that won't work obviously. :-)

But try this:
  1. \documentclass{article}
  2. \usepackage{listings}
  3. \def\dollar{\$}
  4. \lstset{
  5. literate={4>}{\$}1
  6. }
  7. \begin{document}
  8. \dollar
  9. \begin{lstlisting}
  10. \dollar
  11. \$
  12. 4>
  13. \end{lstlisting}
  14. \end{document}


Now every instance of 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 §?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

schweinhundert
Posts: 5
Joined: Thu Sep 12, 2013 8:01 am

Postby schweinhundert » Tue Aug 12, 2014 5:51 am

Nice, the latter works (with a special character). Thank you.

Any chance of a fix for this?

User avatar
Johannes_B
Site Moderator
Posts: 3615
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Aug 12, 2014 10:08 am

Since i am not the developer, take a look at the TeXnicCenter Support. Make sure, to bump an existing issue before creating a new ticket.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.


Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests