I use tex4ebooks the first time. I thought today that I managed to get indexing with it, but then at the final step an encoding problem arose, which I already solved with the help of the forum.

But now an undefined control sequence come with the minimal example as following:

The config for tex4ebook shows this:

% You can also add more authors to your ebook metadata:
\Configure{OpfMetadata}{\HCode{<dc:creator>An author</dc:creator>}}
\Configure{OpfMetadata}{\HCode{<dc:title>A title</dc:title>}}
\Configure{OpfMetadata}{\HCode{<dc:publisher>A publisher</dc:publisher>}}
\Configure{OpfMetadata}{\HCode{<dc:date opf:event='Originalausgabe'>2023</dc:date>}}

The indexing4ht.sty is as follows:

% Befehl zum Abrufen der vollständigen Abschnittsnummer für den aktuellen Abschnittsbefehl
  \ifnum\c@section=0 %
  \ifnum\c@subsection=0 %
  \ifnum\c@subsubsection=0 %

(define-attributes (("default" "definition" "textbf")))
(define-location-class "sec-num" :var
 :sep "."  "arabic-numbers"
 :sep "."  "arabic-numbers"
 :sep "."  "arabic-numbers"
 :sep "."  "arabic-numbers"))
(require "texindy.xdy")
(markup-keyword :open "\idxkeyword{" :close "}")
(markup-locref :open "\idxlocator{" :close "}")
(markup-locref :open "\textbf{\idxlocator{" :close "}}" :attr "textbf")
(markup-locref :open "\textbf{\idxlocator{" :close "}}" :attr "definition")

An the indexing4ht.4ht shows:

}{%ToDo: Provide configuration for index writing without imakeidx

% because imakeidx has support for multiple indices, we need to select a
% right one
% default index name is \jobname

% configure variable which is saved on every index call
% section mark is used by default, other possible values may be paragraphs, or
% links to individual index entries

% we need to suppress adding of multiple identical identifiers
    % save identifier only if it haven't been used yet
  \expandafter\ifcsname usedsec\a:indexvalue\endcsname
  \expandafter\gdef\csname usedsec\a:indexvalue\endcsname{yes}

% print index locators. make links to destinations in document


% to support crossreferencess, we save index keyword with unique identifier


  \global\advance\idxkwdcnt by 1\relax%
  % use tags only one time


  \a:see\ \ifTag{idxkw#1}{\a:seeLink{\Ref{idxkw\GetTitleStringResult}}{}#1\b:seeLink}{#1}

% make link configurable, in order to enable user to add custom parameters


  \a:seealso\ \ifTag{idxkw#1}{\a:seeAlsoLink{\Ref{idxkw\GetTitleStringResult}}{}#1\b:seeAlsoLink}{#1}


\Configure{seealso}{\textit{siehe auch}}

And finally the makefile mymakef.mk4 is this:

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

Then I run first

tex4ebook -a debug -c myconfig.cfg -m index -e mymakef.mk4 Sourcename.tex

And then call xindy manually to get the .ind file

call xindy -L german -C duden-utf8 -I latex -M Sourcename.xdy Sourcename.idx

And then I run tex4ebook again an get the undefined controll sequence error:

Undefined control sequence.
l.9   \item \idxkeyword
                       {Ende}, \idxlocator{4}

The tex-file finallly is this as minimal example:

\makeindex[intoc=false,columns=1,noautomatic,title=Alphabetisches Verzeichnis]

    Praxis und Übungen\index{Uebungen@Übungen}
    \section{Abschnitt Eins}
    Zwei Welten\index{Welten} und Ähren im Feld.
    \section{Abschnitt Zwei}    
    Beginn und Ende\index{Ende}

Maybe someone knows the clue to the door. Thank you.


1 Answer 1


Indexing is now supported out of the box in TeX4ht, so you don't really need the indexing4ht package. You can remove it from your .cfg file. I also had to remove Make:biber {} from your build file, because you don't use BibLaTeX in the example, and it resulted in an error.

For German-Duden, try this build file:

if mode=="draft" then
  Make:htlatex {}
  Make:htlatex {}
  Make:xindy {language="german-duden"}
  Make:htlatex {}
  Make:htlatex {}

The up-to-date information about indexing is available in this how to.

This is how your index looks in Calibre:

enter image description here

  • Thank you, how did you do that? I removed indexinght.sty and Make:biber {}. And started from scratch, with 1. tex4ebook like above mentioned 2. xindy like above mentioned and 3. again tex4ebook. But I get the same error message. Do I have the newest tex4ebook version? --> Version 0.3h. Is this new enought?
    – Thomkrates
    Commented Mar 12, 2023 at 19:54
  • xindy shows the info lines: "Encountered unexpected char '\' on line 1 Encountered unexpected char 'b' on line 1 Encountered unexpected char 'e' on line 1 Encountered unexpected char 'f' on line 1 ..." Is this again an encoding problem?
    – Thomkrates
    Commented Mar 12, 2023 at 20:10
  • @Thomkrates you don't need to run Xindy manually, it is called automatically from the build file, with necessary post-processing steps.
    – michal.h21
    Commented Mar 12, 2023 at 20:34
  • Thank you. Unfortunately I do not got your result. The index in the epub is without hyperref. And additionally with the minimal example, I got two table of contents in the epub und doubled. - Is this intentious? - The latest version of tex4ebook is 0.3i. I copied the files in appropriate folder.
    – Thomkrates
    Commented Mar 12, 2023 at 21:03
  • @Thomkrates yes, the double TOC is intentional, this fixes a bug with split chapters, where the TOC was in a separate page and there was no way how to go from the main HTML file to subpages. So now the main TOC is printed in the main page, but you will get an extra TOC when you use \tableofcontents. You can disable the second TOC using \ifdefined\HCode\else\tableofcontents\fi.
    – michal.h21
    Commented Mar 12, 2023 at 21:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .