[Tex/LaTex] How to use Xindy with MiKTeX

installingmiktexxindy

Obsolete since end of June, 2015.

As probably widely is known, the indexing tool Xindy is not included in the TeX distribution MiKTeX. Because MakeIndex does not work well with Unicode, but Xindy does, I therefore have a question:

Could Xindy installed by hand, and, if yes, how could this be done?

Best Answer

My following answer is obsolete since end of June, 2015. I’ve got the internal MiKTeX version with the update from 25 of June 2015, but apparently others got it already one week earlier.

Note, that for now there is an issue, if you’ve installed MiKTeX into a path containing spaces – as it is the default, when you used the C:\\Program Files\ or C:\\Program Files (x86)\ system folders. See wolfi’s answer to the according question MiKTeX and Xindy problems .


Yes, it is possible.

Remark: Several posts have been made to LaTeX-Community.org – see Installing Xindy in MikteX and finally Xindy for MiKTeX, but you will find some issues there. First, the user “lartkma” provided some files, which were uploaded to Megaupload.com, but this service is down for known reasons (see Megaupload legal case on Wikipedia). Second, I strongly discourage his advice on how to install Xindy into the main MiKTeX installation path. I wrote about this in my answer to Purpose of local texmf trees. But in the end all following instructions are still derived from lartkma’s work.

More recently a feature request has been made to include xindy in MikTeX, which also includes detailed, up-to-date installation advice.

Prerequisite: You need a Perl interpreter – you need it anyway for the Perl scripts in MiKTeX, cf. my answer to MiKTeX and Perl scripts for advices.

If Perl is properly installed, follow the directions!

  1. If you didn’t already have created a local texmf path, do it now. See Create a local texmf tree in MiKTeX.

    For Xindy you will need this structure:

    <localtexmf>
         |
         |--doc
         |   |
         |   +--xindy
         |
         |--miktex
         |   |
         |   +--bin
         |
         |--scripts
         |     |
         |     +--xindy
         |
         +--xindy
             |
             +--modules
    

    Don't forget to add the folder <localtexmf>\miktex\bin to the system variable Path in Windows.

    Nota bene: In earlier versions of this answer the recommended binary path was <localtexmf>\bin, and I personally still prefer this path. What I actually did – and want to give as advice to you – was that I created a symbolic link from <localtexmf>\miktex\bin to <localtexmf>\bin, and I did not add the new link to the system path variable. Cf. also Wikipedia: Symbolic link in Microsoft Windows. As long as you are on the same drive it does not matter, whether you use a soft link or a junction (see also on Superuser.com: directory junction vs directory symbolic link?). BTW instead of Microsoft’s own command line tools I prefer Link Shell Extension.

  2. Get the Xindy package provided by W32TeX: http://mirror.ctan.org/systems/win32/w32tex/xindy-w32.tar.xz – this file contains all you need.

    Remark: Ensure the date of the file is 16.4.2014 or later. The file tex2xindy.exe in the bin folder should have a date of 14.4.2014 or later. If unsure download directly from the W32TeX website.

  3. Extract all files into a temporary folder. You need a program, which can unpack XZ files (and also TAR, but that’s common). My suggestion is 7-Zip or PeaZip.

    The files tex2xindy.exe, xindy.mem, and xindy-list.exe from the bin folder go into <localtexmf>\miktex\bin (the two .dll-files and the other two .exe-files and are not needed anymore), all contents of share\texmf-dist\doc go into <localtexmf>\doc and so on for the others.

  4. If you’ve copied the files xindy.exe and texindy.exe into <localtexmf>\miktex\bin, delete them.

    In the <localtexmf>\miktex\bin folder create two empty text files with the names xindy.bat and texindy.bat. If you like this more, you can also choose .cmd as file extension, but the filenames must not be changed!

    Copy the following lines into xindy.bat and adjust the script path to your settings:

    @echo off
    set ScriptPath=<localtexmf>\scripts\xindy
    perl %ScriptPath%\xindy.pl %*
    

    For texindy.bat the content must be slightly different, of course:

    @echo off
    set ScriptPath=<localtexmf>\scripts\xindy
    perl %ScriptPath%\texindy.pl %*
    

    Remark: The second and third line could be merged in both cases, but in my opinion the above version is far more readable.

    If you use the default text editor Notepad, in the save dialogue make sure, that you do not save to a file with .txt extension: Save with double quotes "xindy.bat".

  5. Refresh your filename data base (FNDB). How to do, is (for instance) also described in Create a local texmf tree in MiKTeX.

  6. In your favorite TeX editor you perhaps need to add a call to Xindy. Because this is different for every editor, I cannot write anything about this here.

Happy Indexing!

Here two test cases, in your favorite task manager you will see the execution of perl.exe and xindy-lisp.exe:

  • Creating an index:

    For convenience I used the package imakeidx, because with the option xindy you get there an automatic call to Xindy (actually it’s texindy!) without any configuration, but for this you must first add the switch --enable-write18 to the call of pdflatex (or the alias --shell-escape).
    Note, with texifyit’s a bit different: --tex-option="--enable-write18".

    \documentclass{article}
    \usepackage[latin,english]{babel} % needed for "blindtext",
                                      % "english" is the active language
    \usepackage{blindtext,lipsum,kantlipsum}
    
    \usepackage[xindy]{imakeidx}
    \makeindex[columns=1]
    
    \begin{document}
    
    \section*{Package \texttt{blindtext}}
    
    \subsection*{English blindtext}\index{blindtext (package)!english}
    %%% see below before section "kantlipsum" for
    %%% \index{blindtext (package)!english|seealso{kantlipsum}}
    \blindtext[1]
    
    \subsection*{Latin blindtext}\index{blindtext (package)!latin}
    %%% see below before section "kantlipsum" for
    %%% \index{blindtext (package)!latin|seealso{lipsum}}
    {\selectlanguage{latin}% note the grouping
    \blindtext[1]}
    
    \newpage
    
    \index{blindtext (package)!english|seealso{kantlipsum}}
    \index{blindtext (package)!latin|seealso{lipsum}}
    
    \section*{Package \texttt{kantlipsum}}\index{kantlipsum}
    %%% see below before "\printindex" for
    %%% \index{kantlipsum|seealso{blindtext (package) with english option}}
    \kant[123]
    
    \section*{Package \texttt{lipsum}}\index{lipsum}
    %%% see below before "\printindex" for
    %%% \index{lipsum|seealso{blindtext (package) with latin option}}
    {\selectlanguage{latin}% actually not needed here
    \lipsum[123]}% note the grouping again
    
    \newpage
    
    \index{kantlipsum|seealso{blindtext (package) with english option}}
    \index{lipsum|seealso{blindtext (package) with latin option}}
    
    \printindex
    
    \end{document}
    
  • Creating a glossary with package glossaries:

    testfile.tex:

    \documentclass{article}
    
    \usepackage[xindy]{glossaries}
    \makeglossaries
    
    \newglossaryentry{gloss}{
    name=glossaries,
    description=A package for generating glossaries in many styles
    }
    
    \begin{document}
    
    \texttt{\gls{gloss}} is a great package!
    
    \printglossaries
    \end{document}
    

    After one latex compilation, run makeglossaries testfile on command line. With options and filename above this will in background make a call of

    xindy -L english -I xindy -M "testfile" -t "testfile.glg" -o "testfile.gls" "testfile.glo"

    After a second latex run you should see the result. For other settings you must read the documentation of glossaries.