1

Sometimes pygments puts characters in red boxes, and I'd like to disable this feature.

In the following example:

\documentclass[a4paper,10pt]{report}
\usepackage[latin1]{inputenc}
\usepackage[francais]{babel}
\usepackage{pythontex}

\begin{document}

\begin{pygments}{python}
>>> a = "L'été sera chaud"
>>> zeros(4, 0)
AssertionError: Dimensions négatives ou nulles.
\end{pygments}

\end{document} 

the first two "é" are correctly displayed, but the last one in "négatives" is boxed, and I'd like to remove this ugly box.

I apologize for this newbie question, but I couldn't find any help in the massive pygments documentation, wich is way too complex for me.

Cristo
  • 647
  • For me, saving as Latin1 and trying to run pythontex gives errors: I can see the box you are talking about in UTF-8 encoding. – Joseph Wright Jan 19 '14 at 13:27

1 Answers1

3

You could use the pycon lexer instead of python. It's made for dealing with Python console content and eliminates the problem you're seeing.

In terms of the red boxes, I usually see them around some characters (anything beyond ASCII?) that are outside of a string (or, in the pycon case, outside of a string or error message). This appears to be a limitation/bug in Pygments.

Also, in case anyone tries to compile the example: you need to run pythontex with --encoding=latin1.

G. Poore
  • 12,417
  • With the pycon lexer it don't recognize "AssertionError" as a specific python expression, so everthing is printed as a simple output string with no coloring :/ – Cristo Jan 19 '14 at 18:38
  • 1
    @Cristo I'm afraid that's all Pygments provides. To get anything more, I think you would need a custom Pygments lexer. – G. Poore Jan 19 '14 at 19:53