# Error with accent characters in index item with tex4ebook and xindy (Texlive 2020)

This is a follow-up of my previous question here. I'm using texlive 2020 and using the files provided by @Michal.h21.

I have modified the input file sample.tex.

\documentclass[ebook,12pt,oneside,openany]{memoir}

\usepackage{lipsum}

\usepackage[backend=biber,hyperref=auto,backref=true]{biblatex}
\bibliography{test}

\usepackage{imakeidx}
\makeindex[intoc=true,columns=1,noautomatic]

\usepackage[hyperindex=true]{hyperref}

\title{Book}
\author{Author}
\date{}

\begin{document}

\maketitle

\frontmatter

\tableofcontents \newpage

\mainmatter

\chapter{C1}

aword\index{aword}

\lipsum \newpage

\chapter{C2}

bword\index{bword}

\index{Muller@M\"{u}ller}

\lipsum \newpage

zword\index{zword}

\backmatter

\printindex

\end{document}


The configuration and build files are the same as the previous question and again provided by @Michal.h21.

ebook.cfg:

% save the clearpage before it is redefined by tex4ht
\let\oldclrearpage\clearpage
% define macro for newpage insertion
\def\mypagebreak{\Configure{newpage}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="newpage"></div>}}}
%
\Preamble{xhtml}
\CutAt{section}
%
% enforce newpage
%
% define it for \newpage
%
\mypagebreak
\Css{.newpage{page-break-before:always;}}
% modify \Configure{BODY} so our confiurations work on all extracted pages
\Configure{@BODY}{\def\clearpage{\bgroup\mypagebreak\oldclrearpage\egroup}}
\Configure{@/BODY}{\global\let\clearpage\oldclrearpage\Configure{newpage}{}}
\begin{document}
\EndPreamble


build.mk4

[ERROR]   htlatex: ./sample.ind [15 9    Missing \$ inserted.
[ERROR]   htlatex: ./sample.ind [15 13   Missing } inserted.


sample.idx

\beforeentry{samplech1.html}{dx3-2001}{}
\indexentry{aword}{3}
\beforeentry{samplech2.html}{dx4-3001}{}
\indexentry{bword}{9}
\beforeentry{samplech2.html}{dx4-3002}{}
\indexentry{Muller@M\"{u}ller}{9}
\beforeentry{samplech2.html}{dx4-3003}{}
\indexentry{zword}{13}


sample.ind

\begin{theindex}
\indexspace
\textbf{A}\label{L-xindex-A}
\nopagebreak[4]
\indexspace
\textbf{B}\label{L-xindex-B}
\nopagebreak[4]
\indexspace
\textbf{M}\label{L-xindex-M}
\nopagebreak[4]
\indexspace
\textbf{Z}\label{L-xindex-Z}
\nopagebreak[4]
\end{theindex}


Update 2:

There are two issues still for the ebook.

The toc in the pdf file is correct and the links work- see below.

Is there any way to fix this thank you.

Update 3:

The index now shows in the toc using the new imakeidx.4ht.

I added an extra line to the build file to get the links to work. It's now

if mode=="draft" then
Make:htlatex {}
else
Make:htlatex {}
Make:xindy {modules={"utf8-lang"}}
Make:biber {}
Make:htlatex {}
Make:xindy {modules={"utf8-lang"}}
Make:htlatex {}
end


Is this the best or most efficient way?

I also changed the xindy module to utf8-lang as above and added a new line

S\'{e}an\index{Sean@S\'{e}an}


in the input file and it worked as well. Is this the best way to deal with character accents from

https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Escaped_codes


and not just german ones?

There is still one minor issue with the index. There is a missing space between "aword" and the "B" header:

Thank you.

• Does it work with \index{Muller@Müller}? May 12, 2020 at 8:09
• No using the accented character gives a UseRawInputEncoding error. May 12, 2020 at 8:45

I've changed the indexing support in make4ht and tex4ebook, so you don't need to use imakeindex.4ht anymore. You can delete it. Instead, built-in TeX4ht indexing support can be used.

The build.mk4 file can look like this:

if mode=="draft" then
Make:htlatex {}
else
Make:htlatex {}
Make:xindy {modules={"duden-utf8"}}
Make:biber {}
Make:htlatex {}
Make:htlatex {}
end


The Make:xindy command is built-in make4ht command. There are also Make:xindex and Make:makeindex commands. See the make4ht documentation for more details.

This is the resulting index in the Epub file, compiled using

tex4ebook -l -c epub.cfg -e build.mk4 filename.tex


Every term has now distinct number, so index contains all used terms. This is a difference to the previous version, where terms were sorted under section numbers.

Edit:

For the intoc option imakeidx support, try the following version of imakeidx.4ht:

% imakeidx.4ht (2020-05-18-14:06), generated from tex4ht-4ht.tex
% Copyright 2019 TeX Users Group
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions
% of LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2020-05-18-14:06}

\expandafter\protected@write\csname#1@idxfile\endcsname{}%
}{\a:makeindex}}%
\o:imki@wrindexentrysplit:{#1}{#2}{#3}%
}
\HLet\imki@wrindexentrysplit\:temp

\ifx \a:makeindex\:UnDef
\NewConfigure{makeindex}{}\Configure{makeindex}{}
\fi

\Hinput{imakeidx}
\endinput


I've updated TeX4ht sources, so it should work everywhere soon.

• @user41974 ah, binhex.tex should be part of your installation. it is in texmf-dist/tex/generic/kastrup/binhex.tex in my install. it is needed for accented characters with LuaTeX or XeTeX. May 13, 2020 at 12:05
• @user41974 ah, I've replaced \index{Muller@M\"{u}ller} with \index{Müller} and it worked. This seems like a bug in Xindex, as it introduces wrong characters in the generated .ind file: \item M\({u}ller, {7}. It works correctly with Xindy. But I would use accented characters anyway and then Xindex works well. May 14, 2020 at 8:38
• @user41974 and do you use LuaTeX (with make4ht -l option)? Accented version should definitely work. If accent doesn't work, you can use the ASCII version with Xindy May 14, 2020 at 11:55
• @user41974 sure, please see the edit May 14, 2020 at 12:49
• @user41974 sorry that was syntax error in the build file. It should be fixed now, it works with tex4ebook and make4ht as well. May 14, 2020 at 15:27