# Index sorting problems with Vietnamese

I have trouble with sorting my index since it is in Vietnamese. I know, this question has been asked already but the problem is that I don't really understand the answer - it seems so complicated... I am using the MiKTeX distribution on Windows and I don't really get the idea of xindy, texindy etc. I have no idea how to implement that and make it run properly. Does anyone know if this has been somewhere explained in basic language or could someone possibly tell me please (as simply as possible) what to put where so that it works?

\documentclass[12pt,oneside,titlepage,headings=small,makeidx]{scrbook}
\usepackage{scrpage2}
\usepackage{cmap}
\usepackage{ulem}
\usepackage[utf8x]{inputenc}
\usepackage[vietnam,polish,english,ngerman]{babel}
\usepackage[T5,T1]{fontenc}
\usepackage{longtable}
\usepackage{lmodern}
\usepackage{makeidx}
\usepackage[columns=2,itemlayout=abshang]{idxlayout}
\usepackage{etoolbox}

\newcommand*\de{\fontencoding{T1}\selectfont\selectlanguage{ngerman}}
\newcommand*\en{\fontencoding{T1}\selectfont\selectlanguage{english}}
\newcommand*\pl{\fontencoding{T1}\selectfont\selectlanguage{polish}}
\newcommand*\vn{\fontencoding{T5}\selectfont\selectlanguage{vietnam}}

\makeindex

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}

\ifoot[]{}
\cfoot[]{}
\ofoot[\pagemark]{\sffamily\pagemark}

\begin{document}
\frontmatter
\title{\pl xxxxxxxx}
\subtitle{\pl xxxx}
\author{\pl xxxxxx}
\date{}
\maketitle
\pl \tableofcontents
\mainmatter

Here comes plenty of text.

\index{\vn giá}
\index{\vn gạo}
\index{\vn ạ}
\index{\vn khi}
\index{\vn cho}
\index{\vn được}
\index{\vn trong}
\index{\vn ứng}
\index{\vn trang}
\index{\vn ô}
\index{\vn dưới}
\index{\vn trước}

\backmatter
\clearpage
\printindex
\end{document}


And this is being produced:

As you can see, all the special characters are being thrown out to the beginning of the alphabet.

This problem has already been discussed i. a. here. But I don't get it. It's too complex...

• Welcome to stackexchange, can you complete your MWE, i don't understand vietnamese, i try to help. in additionnal, try to add a screen capture of the result. – Hamza.w Jun 26 '15 at 18:19

I get a satisfactory result if I do

\documentclass[12pt,oneside,titlepage,headings=small,makeidx]{scrbook}
\usepackage{scrpage2}
\usepackage{cmap}
\usepackage{ulem}
\usepackage[utf8]{inputenc}
\usepackage[vietnam,polish,english,ngerman]{babel}
\usepackage[T5,T1]{fontenc}
\usepackage{longtable}
\usepackage{lmodern}
\usepackage{makeidx}
\usepackage[columns=2,itemlayout=abshang]{idxlayout}
\usepackage{etoolbox}

\newcommand*\de{\fontencoding{T1}\selectfont\selectlanguage{ngerman}}
\newcommand*\en{\fontencoding{T1}\selectfont\selectlanguage{english}}
\newcommand*\pl{\fontencoding{T1}\selectfont\selectlanguage{polish}}
\newcommand*\vn{\fontencoding{T5}\selectfont\selectlanguage{vietnam}}

\makeindex

\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}

\ifoot[]{}
\cfoot[]{}
\ofoot[\pagemark]{\sffamily\pagemark}

\newcommand{\rawindex}[1]{\expandafter\index\expandafter{\detokenize{#1}}}

\begin{document}
\frontmatter
\title{\pl xxxxxxxx}
\subtitle{\pl xxxx}
\author{\pl xxxxxx}
\date{}
\maketitle
\pl \tableofcontents
\mainmatter

Here comes plenty of text.

\rawindex{\vn giá}
\rawindex{\vn gạo}
\rawindex{\vn ạ}
\rawindex{\vn khi}
\rawindex{\vn cho}
\rawindex{\vn được}
\rawindex{\vn trong}
\rawindex{\vn ứng}
\rawindex{\vn trang}
\rawindex{\vn ô}
\rawindex{\vn dưới}
\rawindex{\vn trước}

\backmatter
\clearpage
\printindex
\end{document}


and then run

xindy -M texindy -L vietnamese -C utf8 dominik.idx


Your way of changing language is, however, not the best I can think of.

• Well, I am still a beginner, so changing the language might for sure be done in a better way, but at least it works since I need to switch within sentences throughout the document. – Dominik Jun 29 '15 at 14:15
• I have one more question: What do you mean saying "and then run xindy -M texindy -L vietnamese -C utf8 dominik.idx"? How do I run that? I just use my editor and know how to compile the document but how do I "run" something? I'm sorry, I guess this is a stupid question, but I really don't know it... :-( Thanks for your forbearance... – Dominik Jun 29 '15 at 14:16
• @Dominik I mean “from the command line”. – egreg Jun 29 '15 at 14:22
• Thanks a lot for your patience. I was helped out of the problem here since something was wrong and that is why I could not have it run. Now it's all fine... BTW: Is there a way to have the sorting done by some command directly in the tex file, skipping the need to execute commands every time after compiling the document? – Dominik Jun 30 '15 at 11:30