6

I am a French student writing with LaTeX. I have a use for multiple index with different names for which I use splitidx. I wanted my indices to appear in the TOC, so I used tocbibind. Everything worked fine but with an accent in one of my index title I get a error message relating to encoding. Here is a MWE (well not working might be more accurate !). Have you got any idea of how I could politely ask tocbibind to expand correctly the indices title in the toc file ?

Thanks a lot.

\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[makeindex]{splitidx}
\usepackage{tocbibind}
\newindex[Index des journaux et séries]{jo}
\newindex[Index des noms de personnes]{np}

\begin{document}

\tableofcontents

Ici du texte avec des accents qui fonctionne : é, à ç, è. Une indexation pour jo\sindex[jo]{phenix@Phenix} et une pour np\sindex[np]{phenix@Phenix}.

\printindex[jo]
\printindex[np] 

\end{document}

I think I see where the problem lies. If I try a chapter with an accent it get written \IeC {\'e} in the toc file whereas my index title always keeps its é even if I put the \IeC {\'e} in the text.

4
  • Try to use a \protect{} around your text with special characters
    – user31729
    Jun 9, 2014 at 17:25
  • I tried, without any success so far. I still got "Package inputenc Error: Unicode char \u8:éri not set up for use with LaTeX ...chapter}{Index des journaux et {séries}}{2}"
    – Chicordine
    Jun 9, 2014 at 17:29
  • Wild try: use \usepackage[french]{babel} Jun 9, 2014 at 17:31
  • It was in my original document, I took it out from the MWE because it had no effect whatsoever on this specific problem. Thanks anyway.
    – Chicordine
    Jun 9, 2014 at 17:34

2 Answers 2

4

The problem is the usage of \xdef in \newindex, which should be \protected@xdef; with \xdef almost any accented character in the index title will produce the error. The tocbibind package is not involved in the issue.

It's a bug that should be fixed by the package author.

\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage[makeindex]{splitidx}
\usepackage{xpatch}
% let's use \protected@xdef instead of \xdef in \newindex
\makeatletter
% there are four occurrences
\xpatchcmd{\newindex}{\xdef}{\protected@xdef}{}{}
\xpatchcmd{\newindex}{\xdef}{\protected@xdef}{}{}
\xpatchcmd{\newindex}{\xdef}{\protected@xdef}{}{}
\xpatchcmd{\newindex}{\xdef}{\protected@xdef}{}{}
\makeatother

\usepackage{tocbibind}
\newindex[Index des journaux et séries]{jo}
\newindex[Index des noms de personnes]{np}

\begin{document}

\tableofcontents

Ici du texte avec des accents qui fonctionne : é, à ç, è. Une indexation pour 
jo\sindex[jo]{phenix@Phenix} et une pour np\sindex[np]{phenix@Phenix}.

\printindex[jo]
\printindex[np]

\end{document}
2
  • Thanks for the explanation, I do feel a little less stupid. I just changed the package but it's good to know where the problem lies.
    – Chicordine
    Jun 15, 2014 at 11:00
  • @Chicordine I believe you should file a bug report to the author of splitidx.
    – egreg
    Jun 15, 2014 at 11:15
2

If you don't stick to splitindex try imakeidx instead, the syntax is similar and there are no errors about special characters, at least not in this example.

\documentclass[10pt,a4paper]{book}
\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage[makeindex]{splitindex}
\usepackage[splitindex]{imakeidx}%
\usepackage{tocbibind}
%\newindex[Index des journaux et séries]{jo}
%\newindex[Index des noms de personnes]{np}

\makeindex[name=jo,title={Index des journaux et séries}]
\makeindex[name=np,title={Index des noms de personnes}]
\begin{document}

\tableofcontents

Ici du texte avec des accents qui fonctionne : é, à ç, è. Une indexation pour jo\index[jo]{phenix@Phenix} et une pour np\index[np]{phenix@Phenix}.

\index[jo]{é@letter é}


\printindex[jo]
\printindex[np] 

\end{document}

I randomly put some index entry there, without direct conjunction to the right place ;-)

enter image description here

3
  • 1
    Oh, for some reason I was going to give the same exact answer. ;-)
    – egreg
    Jun 9, 2014 at 17:45
  • @egreg: I could hardly imagine why ;-)
    – user31729
    Jun 9, 2014 at 17:46
  • Thanks a lot ! I did not know about this package. It works just fine now.
    – Chicordine
    Jun 15, 2014 at 10:56

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.