2

I have problems with index section.

I use tex4ht to compile my manual to html file.

In case if makeindex and begin{document}/end{document} commands are located in included file, compilation if failed.

Simple example

manual.tex file:

\documentclass{article}
\usepackage{makeidx}

\include{index}

index.tex

\makeindex
\title{A Title}
\author{An Author}
\date{July 19, 2004}

\begin{document}
\maketitle  \tableofcontents
\section{First Section}
    Some text.
    \index{first}
\section{Second Section}
\subsection{A Subsection}
    Some text 2
    \index{Second}
\printindex
\end{document}

Compilation Error:

! Argument of \idx:extI has an extra }. \par l.11 \ section{Second Section} ?

!!! However in case if contents of file is located in one file, compilation is successfull.

Separate text into two files is obligatory condition in my case.

Could someone help me?

4
  • You should be using \input instead of \include, even if this is not the cause for the problem.
    – egreg
    Dec 24, 2015 at 14:54
  • '\input' doesn't help with this problem. Dec 24, 2015 at 14:57
  • I know, but \include in that place is conceptually wrong.
    – egreg
    Dec 24, 2015 at 14:59
  • 1
    In your setup, I see that \@wrindex has the definition \warn:idx {#1}\title:chs {\html:addr \hbox {\Link -{}{x\last:haddr }\EndL ink }}{}\edef..., whereas with a “normal” document it is defined as \a:wrindex \o:wrindex:.
    – egreg
    Dec 24, 2015 at 15:05

1 Answer 1

2

Edit:

This answer is obsolete. make4ht has built-in indexing support now. See this answer for an example.

Original answer:

The problem is with name of your included file, because tex4ht tries to include .4ht file for every file which is included. In your case this causes problem, because file index.4ht exists, which should be included for index.sty. An obvious fix is to rename included file to some safe name, like text-index.tex, or something.

Now you only have to compile the index in form usable for tex4ht. It is easy using make4ht build file, manual.mk4:

Make:add("makeindex", function(arg)
  os.execute("tex '\\def\\filename{{${input}}{${sext}}{${iext}}{${dext}}} \\input idxmake.4ht'" % arg) 
  os.execute("makeindex -o ${input}.${dext} ${input}.${iext}" % arg)
end,{sext = "idx", iext ="4dx", dext = "ind"} )

if mode == "draft" then
  Make:htlatex {}
else
  Make:htlatex {}
  Make:makeindex {}
  Make:htlatex {}
  Make:htlatex {}
end

compile the file with

make4ht -u manual.tex

Interesting part of the build file is:

Make:add("makeindex", function(arg)
  os.execute("tex '\\def\\filename{{${input}}{${sext}}{${iext}}{${dext}}}  \\input idxmake.4ht'" % arg) 
   os.execute("makeindex -o ${input}.${dext} ${input}.${iext}" % arg)
 end,{sext = "idx", iext ="4dx", dext = "ind"} )

Make:add creates new command which can be used in a build file. For using makeindex with tex4ht, it is first necessary to post-process the idx file with idxmake.4ht, and it needs to have defined used extensions in \filename command. It creates intermediate file which is then processed by makeindex. the extensions of processed files are given in

{sext = "idx", iext ="4dx", dext = "ind"}

The result:

enter image description here

You must log in to answer this question.

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