8

I'm currently using makeindex to generate an index and was advised by @egreg to use xindy instead to properly manage accents in French. However, I can't find how to reproduce my current settings:

\makeindex[title={Index th\'ematique},intoc,options=-r -s thematique.ist,columns=2]
\newcommand{\themeindex}[1]{\index{#1|transform}}

I then use \themeindex in my text.

thematique.ist contains:

% Dotfill style
headings_flag 1
heading_prefix "\\hfill\{\\dayheadfont\\large\\textbf- "
heading_suffix " -\}\\hfill\\nopagebreak\\vspace\{0.5\\baselineskip\}"
delim_0 "\\dotfill "
delim_1 "\\dotfill "
delim_2 "\\dotfill "
item_0 "\n \\item\\raggedright "
item_1 "\n \\subitem\\raggedleft "

How can I achieve the same with xindy?

3
  • 1
    This requires going deeply in the manual of Xindy. If it existed. :( – egreg Jun 11 '13 at 21:12
  • Is xindy that old? And if it is old and good, why don't people use it more? – raphink Jun 11 '13 at 21:13
  • It's a rather old project, but it lacks documentation. And still has a few problems, unfortunately, in UTF-8 support. – egreg Jun 11 '13 at 21:14
6

It was quite difficult to accomplish this task without a full MWE or a preview of index at hand. I tried that anyway and this is an example of an index with French words. I run these commands:

lualatex mal-xindy-style.tex
xindy -M texindy -C utf8 -L french -M mal-makeindex-style mal-xindy-style.idx
lualatex mal-xindy-style.tex

If we change \usepackage{luatextra} to inputenc (for pdflatex) or to fontspec (for xelatex), this example will be displaying letters with diacritics in those formats.

%! lualatex mal-xindy-style.tex
\documentclass[a4paper]{article}
\usepackage{luatextra} % Use inputenc with pdflatex or fontspec with xelatex to achieve proper displaying of letters with diacritics.
\pagestyle{empty}\parindent=0pt
\usepackage[hyperindex=false, colorlinks]{hyperref}
\usepackage{makeidx}
\makeindex %[title={Index th\'ematique}, intoc, options=-r -s thematique.ist,columns=2]
\newcommand{\themeindex}[1]{\index{#1|malindex}}
\usepackage{filecontents}
\font\dayheadfont=cmr10 %at 12pt
\def\myheadingstart{%\def\indexspace{}%\justify\hfil
  \centering\begingroup\dayheadfont\large\bfseries-- }
\def\myheadingend{ --\endgroup\nopagebreak\vspace{0.5\baselineskip}\par\raggedright}
\def\myown#1{\textit{#1}}
\def\mallettergroup#1{\myheadingstart#1\myheadingend}
\def\malindex#1{\myown{\hyperpage{#1}}}

\begin{document}
\ifx\relax
% An original file for makeindex...
\begin{filecontents*}{thematique.ist} 
% Dotfill style
headings_flag 1
heading_prefix "\\myheadingstart "
heading_suffix " \\myheadingend "
delim_0 "\\dotfill "
delim_1 "\\dotfill "
delim_2 "\\dotfill "
item_0 "\n \\item\\raggedright "
item_1 "\n \\subitem\\raggedleft "
\end{filecontents*}
\fi

% A style file for xindy...
\begin{filecontents*}{mal-makeindex-style.xdy}
(markup-index :open  "\begin{theindex}~n"
    :close "~n~n\end{theindex}~n"
    :tree) 

(markup-letter-group :open-head "~n\mallettergroup{" :close-head "}%")
(markup-letter-group-list :sep "~n~n\indexspace~n")

(markup-indexentry :open "~n\item " :close "" :depth 0)
(markup-indexentry :open "~n  \subitem " :close "" :depth 1)
(markup-indexentry :open "~n    \subsubitem " :close "" :depth 2)
(markup-locclass-list :open "\dotfill " :sep ", " :close "")
(markup-locref-list   :sep ", ")

(define-attributes (("malindex")) )
(markup-locref :attr "malindex" :open "\malindex{" :close "}")
(markup-locref :attr "hyperpage" :open "\hyperpage{" :close "}")
(markup-locref :attr "default" :open "\hyperpage{" :close "}")
\end{filecontents*}

\index{premier niveau}
\index{niveau!1@premier}
\index{niveau!2@deuxième}
\index{niveau!1@premier!1@premier}
\index{niveau!1@premier!2@deuxième}
\themeindex{niveau!2@deuxième!1@premier}
\themeindex{niveau!2@deuxième!2@deuxième}
\index{étrangères}
\index{Ça va}
\index{À quelle}
\themeindex{éteindre}
\themeindex{surhomme}
\themeindex{œil}

\begingroup
% I wish not to have page number in index.
\def\indexname{Index thématique}%
\def\thispagestyle#1{}%
\printindex
\endgroup
My first paragraph\ldots
\end{document}

mwe

7
  • I believe you when you say this took some figuring! I'm even linking and commenting in my source code (not that it wouldn't be obvious this snippet was above my head). The only adjustment and possible contribution was that since I'm using imakeidx and texindy, I cleaned up the things to remember at compile time by moving the language arguments into the xdy file itself (in my case (require "lang/turkish/utf8-lang.xdy") and used makeindex[options=-M filename.xdy]. Compiling is then simplified to just running lualatex. Thanks for working out this snippet! – Caleb May 10 '14 at 7:32
  • @Caleb It's good to hear it's working for you after some adjustments! – Malipivo May 10 '14 at 8:07
  • Could something have changed over the last few years? When I run the second command I get the error message: xindy: input file mal-xindy-style.idx does not exist at /usr/local/texlive/2020/bin/x86_64-linux/xindy line 547. under TeXLive'20 – TeX Apprentice Oct 18 '20 at 3:45
  • @TeXApprentice: It works fine for me. Just had to replace -C UTF8 by -C urtf8. Did you name the tex file as mal-xindy-style.tex? – Sergei Golovan Oct 18 '20 at 6:49
  • 1
    @Malipivo, the command should use lowercase -C utf8. Would you edit your answer? – TeX Apprentice Oct 18 '20 at 20:39

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.