I want to use index in Vietnamese Alphabetically. The order must be a, b, c, d, đ, e, ê. But in following code. That order is wrong. The first is "Ê", not "A", the second is "Đ", not "B". How to arrange that order?enter image description here

This is my code



Some text.\index{Apple}\index{Apricot}\index{Avocado}\index{Banana}
\index{Jackfruit}\index{Jambul}\index{Kiwi fruit}\index{Kumquat}
\index{Pomegranate}\index{Purple Mangosteen}\index{Raisin}\index{Raspberry}
\index{Rambutan}\index{Redcurrant}\index{Salal berry}\index{Satsuma}
\index{Star fruit}\index{Strawberry}\index{Tangerine}\index{Tomato}
\index{Ugli fruit}\index{Watermelon}\index{Ziziphus mauritiana}
\index{Đồng biến}
\index{Nghịch biến}
\index{Dao động điều hòa}

3 Answers 3


As Egreg said, makeindex, which is used with imakeidx to produce index by default, doesn't support unicode. There is support for vietnamese in xindy, the other index processor. Unfortunately, there is some problem with pdflatex, Vietnamese language and xindy, because index entries are written as TeX sequences, not utf-8 codes, and xindy is unable to sort them correctly. This doesn't happen with other languages, so it is probably a bug. Nevertheless, you can switch to xelatex, which is good idea for Asian language anyway, and the index is then processed correctly, I hope.

Modified preamble:

\makeindex[columns=3,options={-M lang/vietnamese/utf8-lang}]    

For xelatex, use polyglossia package instead of vietnam, we use xindy option for imakeidx to avoid makeindex usage and options={-M lang/vietnamese/utf8-lang} will use Vietnamese sorting.

compile with xelatex -shell-escape filename. the -shell-escape option enables compilation of the index directly when your document is compiled. if you are not using the command line to compile your document, you must configure your editor to use this option.

The result:

Vietnamese index

Edit: As workaround for pdflatex, I wrote simple filter which convert control sequences generated by inputenc with utf8 option to utf8 characters.



local cmd_arg = [[
iec2utf.lua - Script for converting LaTeX LICR codes to utf8 characters
Usage: cat filename | texlua iec2utf.lua > newfilename

  comma separated list of LaTeX font encodings used in the document

local enc = {}

local licrs = {}
local codepoint2utf = unicode.utf8.char 

function load_encodings(f)
  local file= io.open(f,"r")
  local encodings = file:read("*all")
  for codepoint, licr in encodings:gmatch('DeclareUnicodeCharacter(%b{})(%b{})') do
    local codepoint = codepoint2utf(tonumber(codepoint:sub(2,-2),16))
    local licr= licr:sub(2,-2):gsub('@tabacckludge','')
    licrs[licr] = codepoint

function sanitize_licr(l)
  return l:gsub(" (.)",function(s) if s:match("[%a]") then return " "..s else return s end end):sub(2,-2)
if arg[1] == nil then
  enc = {"T1"}
  for _,n in pairs(arg) do
    enc[#enc+1] = n

for _,e in pairs(enc) do
  local filename = e:lower() .. "enc.dfu"
  local dfufile = kpse.find_file(filename)
  if dfufile then

local input = io.read("*all")

local cache = {}

local output = input:gsub('\\IeC[%s]*(%b{})',function(iec)
  local code = cache[iec] or licrs[sanitize_licr(iec)] or '\\IeC '..iec
  -- print(iec, code)
  cache[iec] = code
  return code


save this script to the same directory as your tex file. This script takes as parameter used font encoding, which is T5 in the case of Vietnamese.

if you are using Windows, you can create batch script to use this filter:


@echo of
type %~n1.idx | texlua iec2utf.lua T5 | texindy -i -M lang/vietnamese/utf8-lang -o %~n1.ind

for Linux, create shell script vietxindy:

#!/usr/bin/env sh
texlua iec2utf.lua T5 < `basename $1 .tex`.idx | texindy -i -M lang/vietnamese/utf8-lang -o `basename $1 .tex`.ind 

And then compile the document with:

pdflatex filename 
vietxindy filename
pdflatex filename

from the command line

  • I can not compile with xelatex -shell-escape filename. Please help me. Thank you. Sep 3, 2013 at 14:56
  • @minthao_2011 doest it fail with some error message?
    – michal.h21
    Sep 3, 2013 at 15:13
  • No. I don't know how to compile with xelatex -shell-escape filename. Sep 3, 2013 at 15:57
  • @minthao_2011 do you compile from the command line, or directly from your text editor?
    – michal.h21
    Sep 3, 2013 at 18:01
  • I get the warning Package expl3 Error: Mismatched LaTeX3 packages detected Sep 3, 2013 at 23:19

Here's another possible solution that uses glossaries instead:








Some text.\glsindex{Apple}\glsindex{Apricot}\glsindex{Avocado}\glsindex{Banana}
\glsindex{Jackfruit}\glsindex{Jambul}\glsindex{Kiwi fruit}\glsindex{Kumquat}
\glsindex{Pomegranate}\glsindex{Purple Mangosteen}\glsindex{Raisin}\glsindex{Raspberry}
\glsindex{Rambutan}\glsindex{Redcurrant}\glsindex{Salal berry}\glsindex{Satsuma}
\glsindex{Star fruit}\glsindex{Strawberry}\glsindex{Tangerine}\glsindex{Tomato}
\glsindex{Ugli fruit}\glsindex{Watermelon}\glsindex{Ziziphus mauritiana}
\glsindex{Đồng biến}
\glsindex{Nghịch biến}
\glsindex{Dao động điều hòa}



Image of index

Requires (pdf)latex, makeglossaries, (pdf)latex


Further information on using the glossaries package:


This is my way, for example, if I want to sort ếch, I typed \index{eesch@ếch}

\index{Uwsnd dujng@Ứng dụng}
\index{ddoofng bieesn@đồng biến}
\index{nghijch bieesn@nghịch biến}
\index{Dao ddoojng ddieefu hoaf@Dao động điều hòa}

enter image description here

You must log in to answer this question.

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