latex formatter after CPP lexer with texcomments=true affects the argument of #include

Create issue
Issue #1505 new
George PAtrick created an issue

In python the statement

pygments.highlight(fh_chunk.read(), CppLexer(), LatexFormatter(texcomments=True),sys.stdout)

resulted in the code line

include <type_traits>

being pygmentized as

\begin{Verbatim}[commandchars=\{},codes={\catcode\$=3\catcode\^=7\catcode`_=8}] ... \PY{c+cp}{\PYZsh{}}\PY{c+cp}{include} \PY{c+cpf}{\PYZlt{}type_traits>} ... \end{Verbatim}

whereupon latex emitted the error

! Missing $ inserted.

because of the underscore in "type_traits" is being interpreted as subscript. The error does not occur without "texcomments=true". Presumably "texcomments=true" should not affect anything but comments.

Comments (0)

  1. Log in to comment