I'm trying to typeset Python programs with LaTeX and the Minted package. I'm under Ubuntu 15.10, with TeXlive installed from Ubuntu standard repositories. The python-pygment package is at version 2.0.1+dfsg-1. Compiling the code below :

% \setminted{encoding=utf-8}

On importe toute la librairie Tkinter (attention, cette écriture ne fonctionne qu'en Python 3)
from tkinter import *

# Creation de la fenetre de base de l'application
# On lui donne un nom
f.title("Découverte de Tkinter")


ends up with the following error :

! Package inputenc Error: Unicode char \u8:�co not set up for use with LaTeX. 
See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
l.7 ...dq{}D�couverte de Tkinter\PYZdq{}}\PY{p}{)}

If I change the « é » in the string into a simple « e », it compiles silently. I've read somewhere it could be useful to set the encoding or outencoding parameter, but I get another error :

! Undefined control sequence.
<recently read> \setminted 
l.7 \setminted

I checked the /usr/share/texlive/texmf-dist/tex/latex/minted/minted.sty file (which is at version 2015/01/31 v2.0) :

user@machine:/usr/share/texlive/texmf-dist/tex/latex/minted# cat minted.sty | grep -E 'encoding|setminted'
\minted@def@optcl{encoding}{-P encoding}{#1}
\minted@def@optcl{outencoding}{-P outencoding}{#1}
          %Need a version of open() that supports encoding under Python 2
            f = open(\"}#1\detokenize{\", \"r\", encoding=\"}\minted@encoding\detokenize{\");
            f = open(\"}\minted@outputdir\jobname.pyg\detokenize{\", \"w\", encoding=\"}\minted@encoding\detokenize{\");
        %Need a version of open() that supports encoding under Python 2
          f = open(\"}#1\detokenize{\", \"r\", encoding=\"}\minted@encoding\detokenize{\");
          f = open(\"}\minted@outputdir\jobname.pyg\detokenize{\", \"w\", encoding=\"}\minted@encoding\detokenize{\");

Following an advice, here is the output from command line compilation with the \listfiles command :

 *File List*
 article.cls    2014/09/29 v1.4h Standard LaTeX document class
  size11.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
inputenc.sty    2015/03/17 v1.2c Input encoding file
    utf8.def    2014/09/29 v1.1m UTF-8 support for inputenc
   t1enc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
  ot1enc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
  omsenc.dfu    2014/09/29 v1.1m UTF-8 support for inputenc
   t1enc.def    2005/09/27 v1.99g Standard LaTeX file
   babel.sty    2014/09/25 3.9l The Babel package
 frenchb.ldf    2015/06/26 v3.1g French support from the babel system
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
  minted.sty    2011/09/17 v1.7 Yet another Pygments shim for LaTeX
fancyvrb.sty    2008/02/07
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
  ifthen.sty    2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
    calc.sty    2014/10/28 v4.3 Infix arithmetic (KKT,FJ)
ifplatform.sty    2010/10/22 v0.4 Testing for the operating system
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
catchfile.sty    2011/03/01 v1.6 Catch the contents of a file (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
  t1cmtt.fd    2014/09/29 v2.5h Standard LaTeX font definitions

So everything seems OK. I'm stuck. It would be great if someone had an idea. Thanks.

  • 1
    It works for me without error in texlive 2015, make sure that your file is saved as utf8 – David Carlisle Dec 30 '15 at 23:48
  • Thanks for answering. My file is saved as UTF-8. I'm on a native UTF-8 system. I usually compiles UTF-8 files without any problem. The present problem is related to the use of the Minted package... – natsirt Dec 30 '15 at 23:49
  • I get this output from your example – David Carlisle Dec 30 '15 at 23:52
  • 1
    I don't see anything particularly that's changed recently, add \listfiles to your example and post the resulting file list from the log can compare package versions – David Carlisle Dec 30 '15 at 23:55
  • 1
    Your log is showing U+FFFD as the character not set up for use with LaTeX, that is the "Replacement (non) character" which is strongly indicative of an encoding error. Latex isn't seeing the é at all. – David Carlisle Dec 30 '15 at 23:58

I was able to solve that (same) problem by using the lualatex-command instead of pdflatex for compiling. LuaLatex is Unicode-capable, so you (just) have to take care of two things in your TeX-file(s):

  • comment out the line where you import/configure the inputenc-Package:

  • rebuild the whole document/project (for example in TexStudio there are two Buttons: "rebuild & view" and "compile". Just compiling e.g. wouldn't create a new Table of Contents , so lualatex would use the old *.toc-file - and could run into encoding errors there.)


I finally succeeded in compiling my document (with UTF-8 characters inside code). I had to remove the TeXlive proposed in Ubuntu standard repositories and install TeXlive 2015. This works with one of my computers running under Ubuntu 15.10.

But the problem remains unsolved with my other computer, which runs with Ubuntu 14.04. Here the python-pygments package is at version 1.6, and I think this is where the problem lies (I updated TeXlive 2015 - not TeXlive from repos - to its latest state before).

I also tried to update the python-pygments package with one backported from Ubuntu 15.10 (v. 2.0.1), but this breaks some things (eg : pygmentize does not work anymore).

If someone had an idea about this... Thanks in advance.

Update : according to the penultimate comment of my question, I'm going to give LuaTeX a try. Thanks for helping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.