# How to use a $sign in minted? I have code like this: \documentclass[11pt]{report} \usepackage{minted} \usepackage{listings} \begin{document} \begin{listing}[ht] \begin{minted}{csharp} private static string Abc() => \$"Abc";
\end{minted}
\caption{Abc}
\label{listing:Abc}
\end{listing}

\end{document}

and i have frame like this (compiled on overleaf):

With Only "$": How can I get rid of the red frame? • Can you please post a complete compilable example? It is easier to help if you post something that can be compiled without having to guess your environment. Sep 12, 2021 at 15:45 • Just speculating: looks, like environment minted might not require backslashing ... so what happens if you delete the backslash? Sep 12, 2021 at 16:33 • @MS-SPO is the same. I embedded new image in post. Sep 12, 2021 at 17:58 • @Thruston of course. Embedded in post. Sep 12, 2021 at 17:59 ## 1 Answer Firstly, you don't need to escape the$.

This is a pygments bug relating to its C# lexer, see https://github.com/pygments/pygments/issues/1573, which has been fixed in pygments 2.10.0, released on August 15th, 2021.

Unfortunately, Overleaf.com's texlive 2021 still provides pygments v2.9.0. You can check by compiling the example below on overleaf:

\documentclass{article}
\usepackage{bashful}
\begin{document}
\bash[stdout]
pygmentize -V
\END
\end{document}

How I find the above info

• The red frame in pdf output is the style of pygments parsing error, indicating it's a pygments issue.
• Then I tested OP's minted snippet both locally and on https://pygments.org/demo/#try, and each of them works ok (with non-escaped $). I also checked$"string" is a valid C# syntax. All that suggest it's a fixed pygments issue.
• So I directly jump to pygments' changelog and search for "c#/csharp". This gives
• Updated lexers:

• [...]
• C# (#1573, #1869)
• I checked #1573 and found it's exactly the same issue OP encountered.
• The rest is straight: checking that issue was fixed and the fixing was published, getting the minimal version containing the fixing (double checked with the sectioning lines in CHANGE).
• How can I use this new version? Sep 12, 2021 at 19:23
• If I try pip install pygments I get that the last version is 2.9.0. On the other hand, the Pygments site says that the last version is 2.10.0. Isn't it weird? Sep 12, 2021 at 20:06
• @M.Jaskuski @egreg I successfully have 2.10.0 installed from pip. Try pip install pygments --upgrade instead or perhaps you should check your pip trusted host. Sep 12, 2021 at 20:13
• @muzimuzhiZ Is It possible to use this on overleaf? Sep 12, 2021 at 21:05
• Unfortunately no. overleaf still provides pygments v2.3.1, kind of outdated. You can see the version by compiling \documentclass{article} \usepackage{bashful} \begin{document} \bash[stdout] pygmentize -V \END \end{document} Sep 12, 2021 at 21:10