[tex4ht] tex4ebook and imakeidx - no hyperlinked index

Michal Hoftich michal.h21 at gmail.com
Wed Sep 12 21:23:44 CEST 2018

Hello Jurgen,

> I am new to this list and can at best be described as "casual LaTeX user" - I use it every year or two for some minor writing project, and then put it aside again (promptly forgetting many of the technical details in the process). For my current writing project, I need to create an epub version of the ebook I am writing. tex4ebook has generally served my needs very well, but now I also want to add an index - or rather, at least two. Some quick research indicated that the imakeidx package was the best tool for this, but now I have hit a snag:
> When I compile the LaTeX files with TeXworks (using the pdfLaTeX + MakeIndex + BibTeX option) I get proper hyperlinked indices like I want. However, if I compile them afterwards with tex4ebook (using cygwin) I do get an epub file... but the index is _not_ hyperlinked, unlike the other components of the epub file (such as the table of contents, footnotes, or other crossreferences using hyperref).

tex4ht has a build in support for makeindex, but it is not really user
friendly. I've create a support for imakeidx package with Xindy as an
index processor. You can find it in the Helpers4ht bundle:


It is not on CTAN, so you need to install it manually, I hope the
instructions in the Install section will work for you. Detailed
description of the usage can be found here:


I've tried to adapt this process to your test file and here is my
solution. I've modified your test file slightly:







This is a test.\index[index2]{Test 1}

This is another test.\index[index1]{Test 2}



The change here is that no automatic index generation is done with tex4ht.

The indexing support must be enabled in the configuration file, like


The Xindy then must be called manually. To ease this task, it is
possible to use a build file. Like this, mybuild.mk4:

Make:add("xindy", function(par)
  par.idxfile = par.idxfile or par.input .. ".idx"
  local modules = par.modules or {par.input}
  local t = {}
  for k,v in ipairs(modules) do
    t[#t+1] = "-M ".. v
  par.moduleopt = table.concat(t, " ")
  local xindy_call = "xindy -L ${language} -C ${encoding} ${moduleopt}
${idxfile}" % par
  return os.execute(xindy_call)
end, { language = "english", encoding = "utf8"})

if mode=="index" then
  Make:htlatex {}
  Make:xindy { idxfile="index1.idx"}
  Make:xindy { idxfile="index2.idx"}
  Make:htlatex {}
  Make:htlatex {}
elseif mode=="draft" then
  Make:htlatex {}
  Make:htlatex {}
  Make:htlatex {}
  Make:htlatex {}

The index generation can be then requested using:

     tex4ebook -m index -c myconfig.cfg -e mybuild.mk4 Test.tex

This should generate the index. As epub file doesn't contain pages,
section numbers are used as pointers instead.

Best regards,

More information about the tex4ht mailing list