I would like to use LaTeX package minted to colorize my c and Cuda code. I need to write comments in the code in czech. I use package inputenc with utf-8 and czech characters (ěščřžýáíé) work good in whole paper but minted block:

LaTeX source:

        double m[4];    // staticky alokované pole

Output pdf:

    double m[4];    // staticky alokovan\unhbox \voidb@x \bgroup \let \unhbox \voidb@x \

EDIT: I have tried XeTeX. minted works fine with XeTeX and czech characters. But assymptote doesn't work for me with XeTeX. asy command used on .asy file from XeTeX utilize 100% of my cpu but not generate any output in casual time.

EDIT: Example for pdflatex:

   \documentclass[a4paper, pt11]{article}
   \usepackage[english, czech]{babel}

   % More symbols


        import unicode;
        fill((0, 0)--(0.5, 0)--(0.5, 1)--(0, 1)--cycle, red);
        fill((0.5, 0)--(6, 0)--(6, 1)--(0.5, 1)--cycle, blue);
        fill((6, 0)--(32, 0)--(32, 1)--(6, 1)--cycle, green);
        draw((0.25, 1.1)--(0.25, 1.9));
        label("znaménko", (0.25,2), N);
        label("exponent", (3.25,1), N);
        label("mantisa", (18,1), N);
        for(int i=0; i < 64; ++i) {
            draw((0.5i, 0)--(0.5i + 0.5, 0)--(0.5i + 0.5, 1)--(0.5i, 1)--cycle);
    \caption{Uspořádání \emph{double} v paměti}

    double m[4];    // staticky alokované pole
    m[0] = 1;       // přímé nastavení první složky
    double *n = (double *) malloc(pocet_cisel * 4 * sizeof (double));   // dynamická alokace
    n[4 + 0] = 1;   // přímý přístup do první složky druhého čísla
    free(n);        // vyčištění paměti
  • Did you try the listings-package?
    – strauberry
    Jun 3, 2011 at 11:47
  • Yes. I have used \lstset{language=C, inputencoding=utf8} and I have got error: Package inputenc Error: Unicode char \u8:�\expandafter not set up for use with LaTeX.
    – snilard
    Jun 3, 2011 at 12:32
  • @snilard: please post your minimal example. Jun 3, 2011 at 13:29

4 Answers 4


Here's a patch for fancyvrb and minted. This should let minted handle whatever Unicode pdfTeX can handle. @KonradRudolph All of this comes down to making sure everything is processed by \detokenize before it is saved to file.

enter image description here

\usepackage[english, czech]{babel}



    %\def\FV@ProcessLine{\immediate\write\FV@OutFile}% %Old, non-Unicode version
    \let\FV@ProcessLine\minted@write@detok %Patch for Unicode
    \immediate\openout\FV@OutFile #1\relax
%% DG/SR modification begin - May. 18, 1998 (to avoid problems with ligatures)
%% DG/SR modification end



double m[4];    // staticky alokované pole
m[0] = 1;       // prímé nastavení první složky
double *n = (double *) malloc(pocet_cisel * 4 * sizeof (double));   // dynamická alokace
n[4 + 0] = 1;   // prímý prístup do první složky druhého císla
free(n);        // vycištení pameti

\mint{c}|double m[4];    // staticky alokované pole|


Edit 2013/07/30

Equivalent code is now incorporated into the minted development version on GitHub.

  • this works for me. +1
    – alvatar
    Feb 3, 2013 at 11:59
  • As alone document this work's for me too. But it hasn't any efect in my thesis. I have absolutely no idea why.
    – snilard
    Mar 24, 2013 at 17:03
  • @snilard If you can come up with a minimal working example, please add another comment or otherwise let me know. Perhaps there's another package you are loading that can cause some sort of conflict.
    – G. Poore
    Mar 25, 2013 at 13:46
  • I am sorry. I did some mistake because It works fine now. Thank you.
    – snilard
    Apr 11, 2013 at 14:47

minted doesn’t fully support inputenc; using external tools in conjunction with Unicode in LaTeX is all but impossible.

You either need to use XeTeX or LuaTeX instead of plain LaTeX, or use another highlighter package instead of minted – but as you’ve seen yourself they have their own share of problems with Unicode.

Personally, I suggest you use XeTeX. It ships with every modern LaTeX system. You just need to use the xelatex or luatex command instead of pdflatex for typesetting.


In my windows7-64 + Python3 + French + 2013-04-30th, this worked for me :

  • python part :
    • install python 3.3 (32bit), and the following sub-projects :
      . easy_install, (necessary to install pygmentize after)
      . pygmentize,
    • to have pygmentize in my path, i had to copy pygmentize.exe and pygmentize-script.py :
      . from C:\Python33\Scripts
      . to C:\Python33
  • tex part :
    • install TexLive or Miketex (2.9+), if not done,
    • check you have xelatex in it, and modules "minted", and "polyglossia",
    • if already yes, maybe check you are up-to-date in those module version,
  • tex editor parametrizing (in texmaker example, may vary for others):
    • use texmaker v4.0.1+ (or >= 3.5.1) (32bit usb or full install version),
    • check its default file saving mode is "utf-8",
    • configure xelatex compilation as follow :
      xelatex -8bit -shell-escape -synctex=1 -interaction=nonstopmode %.tex
      "-8bit" is to replace "TAB" character per beautifull spaces
      "-shell-escape" I don't remember (see other posts)
    • set default "quick compilation" to xelatex+pdf : (indeed, xelatex will compil to .xvd, and only .pdf viewer seems possible)
    • use then "quickcompilation" to transform your .tex into a .pdf.
  • adapting your former ".tex" files :
    • remove {inputenc} , {babel} references from your old .tex,
    • add {polyglossia},
  • working .tex file :

    %Format: WML-LaTeX2e
    %This work for Mathematics+French characters+Minted usage
    %For more complex case
    %\usepackage[ansinew]{inputenc} no more
    %\usepackage[utf8]{inputenc} no more  
    %\usepackage[english, french]{babel} no more
    %\usepackage{fr} no more
    % and now with
    \topmargin -1.5cm 
    \headheight 0cm 
    \headsep 0.8cm 
    \topskip 0cm 
    \textheight 28cm 
    \footskip 1.5cm 
    \textwidth 18cm 
    \oddsidemargin -1cm 
    \evensidemargin 0cm 
    \centerline{\fbox{\begin{minipage}{10cm}\textbf {
     Titre accentué
    \noindent Essai script
    # des caractères français
    for j in range(1,10) :
        print("c'est la fête !")
  • 1
    Welcome to TeX.sx! I've formatted your message using better mark up. In general it's best to avoid <pre> and </br> tags.
    – egreg
    Apr 30, 2013 at 11:05

FWIW, this example works fine with ConTeXt MkII (which uses pdftex engine). Instead of the minted package, I am using vim module for ConTeXt, which is similar to minted but uses vim for highlighting the file.



  double m[4];    // staticky alokované pole

The output file is written correctly. Therefore, it is highlighted correctly by vim, and the resulting pdf is fine. This shows that correct handling of encoding is possible in pdftex and hence should be possible in LaTeX as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .