3

I am creating a template to produce output in EPUB format. I have taken examples from various sources on the web. I finished with a config.cfg file that contains...

\Preamble{xhtml}
\DeclareGraphicsExtensions{.svg,.png,.jpg,.pdf}
\Configure{AddCss}{blitz-lite.css}
\Css{.partimage{margin:0 auto;text-align:center;}}
\Css{.partimage img{max-width:100\%;}}
\Css{.partHead .titlemark{display:block;}}
\DeclareGraphicsExtensions{.svg,.png,.jpg,.pdf}
\begin{document}
    \EndPreamble

a config.mk4 file that contains...

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

if mode=="draft" then
Make:htlatex {}
else
Make:htlatex {}
Make:biber {}
-- xindymodule = Make.params["input"]
Make:xindy {modules = {"sample"}}
Make:htlatex {}
Make:htlatex {}
Make:htlatex {}
end

and an imakeidx.4ht file that contains...

\RequirePackage[]{etoolbox}
\RequirePackage{gettitlestring}
\newcounter{indexcnt}
\let\@Index\@index
\patchcmd{\@Index}{\@wrindex}{\@Wrindex}{}{}
\let\@Wrindex\@wrindex
\patchcmd{\@Wrindex}{\thepage}{\theindexcnt}{}{}
\let\xIndex\index
\patchcmd{\xIndex}{\@index}{\@Index}{}{}
\patchcmd{\xIndex}{\@index}{\@Index}{}{}

\pretocmd{\xIndex}{\@stepindexcnt\@indexanchor}
% \patchcmd{\index}{\@index}{\@Index}{}{}
% \patchcmd{\xIndex}{\@index}{\@Index}{}{}
% \let\protected@iwrite\protected@write
% \let\@index\@Index
% \patchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}
\patchcmd{\@Wrindex}{\protected@write}{\protected@iwrite}{}{}
\let\Index\xIndex
\let\index\xIndex
%\show\Index
\newcommand\@indexanchor{%
\edef\idx@anch{idx-anch\theindexcnt}%
\Link[]{}{\idx@anch}\EndLink%
%\Ref{(idx-link-\idx@anch)}{\FileName/\idx@anch}
}
\newcommand\@stepindexcnt{\stepcounter{indexcnt}}
\newcommand\hello[1]{\@hello#1}
\def\@hello#1/{%
\Link{idx-anch#1}{}#1\EndLink%
}


\GetTitleStringSetup{expand}
\GetTitleStringDisableCommands{%
\renewcommand\LaTeX{LaTeX}
}

\newcount\idxkwdcnt
\LinkCommand\IdxKWLink{span,href,id}
\newcommand\idxkeyword[1]{%
\global\advance\idxkwdcnt by 1\relax%
% use tags only one time
\GetTitleString{#1}
\ifcsdef{idxkw\GetTitleStringResult}{}%
%{\Tag{idxkw#1}{idxkw\the\idxkwdcnt}}%
{\expandafter\Tag\expandafter{idxkw\GetTitleStringResult}{idxkw\the\idxkwdcnt}}%
\csgdef{idxkw\GetTitleStringResult}{x}
\a:IdxKW{}{idxkw\the\idxkwdcnt}#1\b:IdxKW
}


\NewConfigure{IdxKW}{2}
\Configure{IdxKW}{\IdxKWLink}{\EndIdxKWLink}

\newcommand\idxlocator[1]{\Link{idx-anch#1}{}#1\EndLink}%

\begin{filecontents*}{\jobname.xdy}
(define-attributes (("default" "definition" "textbf")))
( define-location-class "sec-num" :var
("arabic-numbers"
: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")
\end{filecontents*}

This is the way I send it to compile...

tex4ebook -l -c config.cfg -e config.mk4 -a debug sample

My example file is called "sample".

What errors am I encountering and I request help as they go beyond my knowledge to solve?

I'm not getting the index on the table of contents page.

When compiling as a PDF, I'm not getting any errors with this imakeidx configuration, and I'm obtaining the author index in the bibliographic apparatus, as well as the concept and onomastic indices.

\usepackage{imakeidx}
\makeindex
\makeindex[name=names,title={Índice de autores}]
\makeindex[name=concepto,title={Índice de conceptos}]
\makeindex[name=onomastico,title={Índice onomástico}]

\DeclareIndexNameFormat{default}{%
    \usebibmacro{index:name}{\index[names]}
    {\namepartfamily}
    {\namepartgiven}
    {\namepartprefix}
    {\namepartsuffix}}
\renewbibmacro*{citeindex}{%
    \ifciteindex
    {\indexnames{labelname}}
    {}}

The function within the tex file is...

\printindex[names]
\printindex[concepto]
\printindex[onomastico]

But it doesn't work with tex4ebook.

I haven't been able to find examples that work with acronyms and glossary. To obtain them in the PDF, I use this code in the preamble and at the end of the tex file.

\usepackage[acronym,sanitizesort,toc=true,nonumberlist]{glossaries}
\makenoidxglossaries

\newglossaryentry{@fal}{
    type=\acronymtype,
    name={FAL},
    description={Fuerzas Argentinas de Liberación},
    first={Fuerzas Argentinas de Liberación (FAL)},
    text={FAL}}


\printnoidxglossary[type=\acronymtype,title={Índice de siglas},toctitle={Índice de siglas}]

Here's a complete example.

\documentclass{book}

\usepackage[spanish]{babel}
\usepackage[style=authoryear,backref=true,hyperref=true,backend=biber]{biblatex}
\addbibresource{test.bib}
\usepackage[babel=true,style=spanish]{csquotes}

\usepackage{graphicx}
\usepackage[texindy]{imakeidx}
%\makeindex
\makeindex[name=names,title={Índice de autores}]
\makeindex[name=concepto,title={Índice de conceptos}]
\makeindex[name=onomastico,title={Índice onomástico}]

\DeclareIndexNameFormat{default}{%
    \usebibmacro{index:name}{\index[names]}
    {\namepartfamily}
    {\namepartgiven}
    {\namepartprefix}
    {\namepartsuffix}}
\renewbibmacro*{citeindex}{%
    \ifciteindex
    {\indexnames{labelname}}
    {}}

\usepackage[allcolors=magenta,colorlinks]{hyperref}

\usepackage{endnotes}
\renewcommand{\notesname}{}
\let\footnote=\endnote

\usepackage[acronym,sanitizesort,toc=true]{glossaries}
\makenoidxglossaries

\author{Alberto Moyano}

\title{Un nuevo mundo}

\newglossaryentry{@uombrera}{
    type=\acronymtype,
    name={UOM},
    description={Universidad Obrera de México},
    first={Universidad Obrera de México (UOM)},
    text={UOM},
    plural={},
    firstplural={}}
    
\begin{document}
\frontmatter

\maketitle

\tableofcontents

\mainmatter

\part{Una parte}

\chapter{1}

\section{Una sección del libro}

Ninguna parte de esta publicación.\footnote{Ninguna parte de esta publicación.}

\gls{@uombrera}

1\index[concepto]{concepto}

1\index[onomastico]{onomastico}

\textcite{Berg1990}

\parencite{Assali2015}

2\index[concepto]{concepto}

2\index[onomastico]{onomastico}

\section{Otra sección del libro}

Ninguna parte de esta publicación.\footnote{Ninguna parte de esta publicación.}

\textcite{Assali2015}

3\index[concepto]{concepto}

3\index[onomastico]{onomastico}

\gls{@uombrera}

\parencite{Berg1990}

4\index[concepto]{concepto}

4\index[onomastico]{onomastico}


\part{Otra parte}

\chapter{2}

\section{Una sección del libro}

Ninguna parte de esta publicación.\footnote{Ninguna parte de esta publicación.}

\gls{@uombrera}

1\index[concepto]{concepto}

1\index[onomastico]{onomastico}

\textcite{Berg1990}

\parencite{Assali2015}

2\index[concepto]{concepto}

2\index[onomastico]{onomastico}

\section{Otra sección del libro}

Ninguna parte de esta publicación.\footnote{Ninguna parte de esta publicación.}

\textcite{Assali2015}

3\index[concepto]{concepto}

3\index[onomastico]{onomastico}

\gls{@uombrera}

\parencite{Berg1990}

4\index[concepto]{concepto}

4\index[onomastico]{onomastico}

\backmatter

\chapter{Capítulo final}

Ninguna parte de esta publicación.\footnote{Ninguna parte de esta publicación.}

\chapter{Notas}
\theendnotes

\printnoidxglossary
\printnoidxglossary[type=\acronymtype,title={Índice de siglas},toctitle={Índice de siglas}]

\printbibliography

\printindex[names]
\printindex[concepto]
\printindex[onomastico]

\appendix

\end{document}

And this is the content of the bib file.

@InCollection{Assali2015,
  hyphenation  = {spanish},
  author       = {Assali, Laura and Lombardi, Alba},
  booktitle    = {Archivos, cultura y patrimonio. I. Jornadas de reflexión sobre la construcción del archivo Centro de Documentación e Investigación de la Cultura de Izquierdas (CEDINCI)},
  date         = {2015},
  keywords     = {listar},
  pages        = {66-78},
  publisher    = {Universidad Nacional de San Martín},
  title        = {Alcances y problemáticas de la documentación de archivo de la Administración Pública Nacional. El caso del Archivo del Ministerio de Relaciones Exteriores y Culto Argentino},
  creationdate = {2023-06-24T18:46:54},
  owner        = {alberto},
}

@Article{Berg1990,
  hyphenation  = {spanish},
  author       = {Berg, Magnus},
  journaltitle = {Historia y Fuente Oral},
  keywords     = {listar},
  number       = {4},
  title        = {Algunos aspectos de la entrevista como método de producción de conocimientos},
  year         = {1990},
  creationdate = {2023-06-24T17:01:42},
  owner        = {alberto},
}

This is a second exercise, where I follow the instructions outlined in the URL provided by michal.h21.

Success is 100%.

\documentclass{book}
\usepackage[spanish]{babel}
\usepackage[style=authoryear,backref=true,hyperref=true,backend=biber]{biblatex}

\usepackage{imakeidx}
\makeindex%indice alfabetico
\makeindex[name=foo,title=Índice de conceptos]
\makeindex[name=foo2,title=Índice de palabras]
\makeindex[name=foo3,title=Índice de onomástico]

\begin{document}
\frontmatter

\tableofcontents

\chapter{1}
    Test1\index{index0 Test1}
    Test2\index[foo]{index1 Test2}
    Test4\index[foo2]{index2 Test4}.
    Test4\index[foo3]{index3 Test4}.

\mainmatter

\chapter{2}
    Test3\index{index0 Test3}
    Test4\index[foo]{index1 Test4}.
    And\index{index0 Test1}.
    Test4\index[foo2]{index2 Test4}.
    Test4\index[foo3]{index3 Test4}.

\backmatter

    \printindex
    \printindex[foo]
    \printindex[foo2]
    \printindex[foo3]
\end{document}

In this third example, I have added the bibliography and everything works with the English language, but it gives errors when switching to Spanish. I am attaching a screenshot.

\documentclass{book}
\usepackage[american]{babel}
\usepackage[style=authoryear,backref=true,backend=biber]{biblatex}
\addbibresource{test.bib}
\usepackage{csquotes}

\usepackage[allcolors=magenta,colorlinks]{hyperref}

\usepackage{imakeidx}
\makeindex%[name=names,title=Índice de autores]
\makeindex[name=foo,title=Índice de conceptos]
\makeindex[name=foo2,title=Índice de palabras]
\makeindex[name=foo3,title=Índice de onomástico]

%\DeclareIndexNameFormat{default}{%
%   \usebibmacro{index:name}{\index[names]}
%   {\namepartfamily}
%   {\namepartgiven}
%   {\namepartprefix}
%   {\namepartsuffix}}
%\renewbibmacro*{citeindex}{%
%   \ifciteindex
%   {\indexnames{labelname}}
%   {}}

\begin{document}
\frontmatter

\tableofcontents

\chapter{1}
Test1\index{index0 Test1}
Test2\index[foo]{index1 Test2}
Test4\index[foo2]{index2 Test4}.
Test4\index[foo3]{index3 Test4}.

\textcite{Assali2015}

\mainmatter

\chapter{2}

\parencite{Berg1990}

\cite{Assali2015}

Test3\index{index0 Test3}
Test4\index[foo]{index1 Test4}.
And\index{index0 Test1}.
Test4\index[foo2]{index2 Test4}.
Test4\index[foo3]{index3 Test4}.

\backmatter

\printbibliography

\printindex
\printindex[foo]
\printindex[foo2]
\printindex[foo3]

\end{document}

enter image description here

It can be observed that I disabled the conversion of the bibliographic author index, as it causes an error when compiling if enabled.

In this test, I managed to prevent it from aborting by using English as the base language. If you examine the code, you will see that now the author name index does not abort, but it also does not appear. Does this mean that the biblatex code has changed?

\documentclass{book}
\usepackage[american]{babel}
\usepackage[style=authoryear,backref=true,backend=biber]{biblatex}
\addbibresource{test.bib}
\usepackage{csquotes}

\usepackage[allcolors=magenta,colorlinks]{hyperref}

\usepackage{imakeidx}
\makeindex
\makeindex[name=names,title=Índice de autores]
\makeindex[name=foo,title=Índice de conceptos]
\makeindex[name=foo2,title=Índice de palabras]
\makeindex[name=foo3,title=Índice de onomástico]

\DeclareIndexNameFormat{default}{%
    \usebibmacro{index:name}{\index[names]}
    {\namepartfamily}
    {\namepartgiven}
    {\namepartprefix}
    {\namepartsuffix}}
\renewbibmacro*{citeindex}{%
    \ifciteindex
    {\indexnames{labelname}}
    {}}

\begin{document}
\frontmatter

\tableofcontents

\chapter{1}
Test1\index{index0 Test1}
Test2\index[foo]{index1 Test2}
Test4\index[foo2]{index2 Test4}.
Test4\index[foo3]{index3 Test4}.

\textcite{Assali2015}

\mainmatter

\chapter{2}

\parencite{Berg1990}

\cite{Assali2015}

Test3\index{index0 Test3}
Test4\index[foo]{index1 Test4}.
And\index{index0 Test1}.
Test4\index[foo2]{index2 Test4}.
Test4\index[foo3]{index3 Test4}.

\backmatter

\printbibliography

\printindex
\printindex[names]
\printindex[foo]
\printindex[foo2]
\printindex[foo3]

\end{document}

The code inside build.lua to achieve this is:

if mode=="draft" then 
  Make:htlatex {} 
else 
  Make:htlatex {} 
  Make:biber {} 
  Make:htlatex{} 
  Make:htlatex{}
end
Make:htlatex {} 
Make:xindy {}
Make:xindy {idxfile = "names.idx"} 
Make:xindy {idxfile = "foo.idx"}
Make:xindy {idxfile = "foo2.idx"} 
Make:xindy {idxfile = "foo3.idx"} 
Make:htlatex {}
Make:htlatex {}

enter image description here

In this 4th example, I have added creating the glossary, and it works 100% effectively. The bibliography author index still does not work.

\documentclass{book}
\usepackage[american]{babel}
\usepackage[style=authoryear,backref=true,backend=biber]{biblatex}
\addbibresource{test.bib}
\usepackage{csquotes}

\usepackage[allcolors=magenta,colorlinks]{hyperref}

\usepackage{imakeidx}
\makeindex
\makeindex[name=names,title=Índice de autores]
\makeindex[name=foo,title=Índice de conceptos]
\makeindex[name=foo2,title=Índice de palabras]
\makeindex[name=foo3,title=Índice de onomástico]

\DeclareIndexNameFormat{default}{%
    \usebibmacro{index:name}{\index[names]}
    {\namepartfamily}
    {\namepartgiven}
    {\namepartprefix}
    {\namepartsuffix}}
\renewbibmacro*{citeindex}{%
    \ifciteindex
    {\indexnames{labelname}}
    {}}

\usepackage{glossaries}
\makenoidxglossaries

\newglossaryentry{latex}
{
    name=latex,description={Is a mark up language suitable for scientific documents}
}

\begin{document}
\frontmatter

\tableofcontents

\chapter{1}
Test1\index{index0 Test1}
Test2\index[foo]{index1 Test2}
Test4\index[foo2]{index2 Test4}.
Test4\index[foo3]{index3 Test4}.

\gls{latex}

\textcite{Assali2015}

\mainmatter

\chapter{2}

\parencite{Berg1990}

\cite{Assali2015}

Test3\index{index0 Test3}
Test4\index[foo]{index1 Test4}.
And\index{index0 Test1}.
Test4\index[foo2]{index2 Test4}.
Test4\index[foo3]{index3 Test4}.

\backmatter

\printnoidxglossary

\printbibliography

\printindex
\printindex[names]
\printindex[foo]
\printindex[foo2]
\printindex[foo3]

\end{document}

Screenshot with glossary.

enter image description here

In this 5th exercise, I have added the list of acronyms, and the result has been 100% successful.

\documentclass{book}
\usepackage[american]{babel}
\usepackage[style=authoryear,backref=true,backend=biber]{biblatex}
\addbibresource{test.bib}
\usepackage{csquotes}

\usepackage[allcolors=magenta,colorlinks]{hyperref}

\usepackage{imakeidx}
\makeindex
\makeindex[name=names,title=Índice de autores]
\makeindex[name=foo,title=Índice de conceptos]
\makeindex[name=foo2,title=Índice de palabras]
\makeindex[name=foo3,title=Índice de onomástico]

\DeclareIndexNameFormat{default}{%
    \usebibmacro{index:name}{\index[names]}
    {\namepartfamily}
    {\namepartgiven}
    {\namepartprefix}
    {\namepartsuffix}}
\renewbibmacro*{citeindex}{%
    \ifciteindex
    {\indexnames{labelname}}
    {}}

\usepackage[acronym,sanitizesort]{glossaries}
\makenoidxglossaries

\newglossaryentry{latex}{
    name=latex,
    description={Is a mark up language suitable for scientific documents}
}

\newglossaryentry{@aaa}{
    type=\acronymtype,
    name={AAA},
    description={Alianza Anticomunista Argentina},
    first={Alianza Anticomunista Argentina (AAA)},
    text={AAA},
    plural={},
    firstplural={}
}
    
\begin{document}
\frontmatter

\tableofcontents

\chapter{1}
Test1\index{index0 Test1}
Test2\index[foo]{index1 Test2}
Test4\index[foo2]{index2 Test4}.
Test4\index[foo3]{index3 Test4}.

\gls{latex}

\gls{@aaa}

\textcite{Assali2015}

\mainmatter

\chapter{2}

\parencite{Berg1990}

\cite{Assali2015}

Test3\index{index0 Test3}
Test4\index[foo]{index1 Test4}.
And\index{index0 Test1}.
Test4\index[foo2]{index2 Test4}.
Test4\index[foo3]{index3 Test4}.

\backmatter

\printnoidxglossary[type=\acronymtype,title={Índice de siglas}]

\printnoidxglossary[title={Glosario de términos}]

\printbibliography

\printindex
\printindex[names]
\printindex[foo]
\printindex[foo2]
\printindex[foo3]

\end{document}

enter image description here

enter image description here

Michal, I managed to get everything working. You have done a great job, and I congratulate you. My mistake was that I hadn't loaded the "indexing=cite" instruction in the biblatex options.

To fix the issue with Spanish, I am using polyglossia.

100% satisfactory

enter image description here

I keep progressing and I have managed to place the notes as a chapter at the end of the book, separating them by chapters.

\documentclass[oneside,onecolumn,openany,final]{book}
\usepackage{polyglossia}
\setmainlanguage{spanish}
\usepackage{csquotes}
\usepackage[style=philosophy-classic,
sorting=nyvt,
annotation=true,
backend=biber,
labeldateparts=true,
backref=true,
useprefix=true,
citereset=chapter,
indexing=cite,
relatedformat=brackets,
publocformat=loccolonpub,
volnumformat=strings,
latinemph=true,
inbeforejournal=true,
shorthandintro=true,
texencoding=utf8,
bibencoding=utf8,
uniquelist=minyear]{biblatex}
\usepackage{imakeidx}
\makeindex[name=names,title=Índice de autores]
\makeindex
\makeindex[name=foo,title=Índice de conceptos]
\makeindex[name=foo3,title=Índice onomástico]
\DeclareIndexNameFormat{default}{%
    \usebibmacro{index:name}{\index[names]}
    {\namepartfamily}
    {\namepartgiven}
    {\namepartprefix}
    {\namepartsuffix}}
\renewbibmacro*{citeindex}{%
    \ifciteindex
    {\indexnames{labelname}}
    {}}
\usepackage[acronym,sanitizesort]{glossaries}
\makenoidxglossaries

\newglossaryentry{latex}{
    name=latex,
    description={Is a mark up language suitable for scientific documents}
}

\newglossaryentry{@aaa}{
    type=\acronymtype,
    name={AAA},
    description={Alianza Anticomunista Argentina},
    first={Alianza Anticomunista Argentina (AAA)},
    text={AAA},
    plural={},
    firstplural={}
}

\usepackage{endnotes,chngcntr}
\def\notesname{Notas}
\let\footnote=\endnote

\makeatletter
\renewcommand\enoteheading{%
    \setcounter{secnumdepth}{-2}
    \chapter*{\notesname\markboth{}{}}
    \mbox{}\par\vskip-\baselineskip
    \let\@afterindentfalse\@afterindenttrue
}
\makeatother

\usepackage{xparse}

\let\latexchapter\chapter

\RenewDocumentCommand{\chapter}{som}{%
    \IfBooleanTF{#1}
    {\latexchapter*{#3}}
    {\IfNoValueTF{#2}
        {\latexchapter{#3}}
        {\latexchapter[#2]{#3}}%
        \addtoendnotes{%
            \noexpand\enotedivision{\noexpand\subsection}
            {\thechapter \, \unexpanded{#3}}}% \chaptername\
    }%
}
\makeatletter
\def\enotedivision#1#2{\@ifnextchar\enotedivision{}{#1{#2}}}
\makeatletter

\usepackage[allcolors=magenta,colorlinks,hyperindex=true]{hyperref}

% fin del preambulo


% base de datos bib
\addbibresource{sample.bib}

\begin{document}
\frontmatter

\tableofcontents

\chapter{Prólogo}

\section*{Sección 1}

Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas \parencite{Berg1990}.\footnote{Nota pie en el frontmatter. Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas.}

\section*{Sección 2}

\textcite{Assali2015}, Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas.\footnote{Nota pie en el frontmatter. Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas.}

Test1\index{index0 Test1}
Test2\index[foo]{index1 Test2}
Test4\index[foo3]{index3 Test4}.

\gls{latex}

\gls{@aaa}

\textcite{Assali2015}

\mainmatter

\chapter{Capítulo dentro del mainmatter}

\section{Sección 1}

Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas \parencite{Berg1990}.\footnote{Nota pie en el mainmatter. Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas \parencite{Berg1990}.}

\section{Sección 2}

\textcite{Assali2015}, Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas.\footnote{Nota pie en el mainmatter. Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas \parencite{Berg1990}.}

Test3\index{index0 Test3}
Test4\index[foo]{index1 Test4}.
And\index{index0 Test1}.
Test4\index[foo3]{index3 Test4}.

\backmatter

\chapter{Conclusiones}

\section*{Sección 1}

Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas \parencite{Berg1990}.\footnote{Nota pie en el backmatter. Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas \parencite{Berg1990}.}

\section*{Sección 2}

\textcite{Assali2015}, Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas.\footnote{Nota pie en el backmatter. Esta obra colectiva da continuidad a uno de los programas centrales impulsados por el Centro de Estudios de Historia Económica Latinoamericana y Argentina (CEHEAL) desde su creación en 2019: el estudio de las ideas y del pensamiento económico en su vínculo con la implementación de políticas económicas \parencite{Berg1990}.}

\begingroup
\parindent 0pt
\parskip 2ex
\def\enotesize{\normalsize}
\theendnotes
\endgroup

\printnoidxglossary[type=\acronymtype,title={Índice de siglas}]

\printnoidxglossary[title={Glosario de términos}]

\printbibliography[title=Referencias]

\printindex[names]
\printindex
\printindex[foo]
\printindex[foo3]


\chapter{Colofón}

La producción de este libro se realizó utilizando el lenguaje LaTeX.

\end{document}

enter image description here

enter image description here

4
  • The current recommendations for indexing with TeX4ht are here: kodymirus.cz/tex4ht-doc/Howto.html#indexing. The imakeidx.4ht is now part of TeX4ht, so you don't need this version, it will probably mess with the indexing commands. I can take a further look on the weekend, could you make a MWE for the TeX file which includes also some \index commands, so I can test it easily?
    – michal.h21
    Commented Jul 6, 2023 at 21:07
  • Thank you. I will upload an example in a few minutes. Commented Jul 6, 2023 at 21:13
  • So everything works correctly with the updated setup?
    – michal.h21
    Commented Jul 7, 2023 at 18:33
  • No. Only with the indexes, I'm currently conducting other tests and I have noticed that the behavior for bibliographic references works fine if the language is English, but it doesn't work with Spanish. The generation of the author index for bibliographic references doesn't work either. I'm still running tests and I will upload a third example with these errors. Commented Jul 7, 2023 at 19:07

1 Answer 1

1

If I understand it correctly, the current issue is this:

  1. various indexes don't work
  2. index titles are not included in TOC.

Ad 1)

The imakeidx package is supported out of the box, your version of imakeidx.4ht doesn't work with current make4ht indexing support.

This is a build file that should work:

if mode=="draft" then
  Make:htlatex {} 
elseif mode=="mini" then
  Make:xindy {idxfile = "names.idx"} 
else
  Make:htlatex {} 
  Make:biber {}
  Make:htlatex {} 
  Make:xindy {} 
  Make:xindy {idxfile = "foo.idx"} 
  Make:xindy {idxfile = "foo3.idx"} 
  Make:xindy {idxfile = "names.idx"} 
  Make:htlatex {}
  Make:htlatex {}
end

It supports the draft mode, so when you want to compile your file faster, you can use

$ tex4ebook -m draft -f epub3 -c config.cfg filename.tex

and the compilation would be much faster. Without -m draft option, it will compile your file with LaTeX several times, and it will run xindy and biber so you get a correct bibliography and indexes. You need to use a separate Make:xindy call for all .idx files that you use.

These are the resulting indexes:

enter image description here

I just found a bug in the processing of index entries in the frontmatter, because they don't contain arabic numerals, but roman numerals. This is a fixed version of make4ht-indexing.lua which should support that:


local M = {}
local log = logging.new "indexing"

-- Handle accented characters in files created with \usepackage[utf]{inputenc}
-- this code was originally part of https://github.com/michal-h21/iec2utf/
local enc = {}

local licrs = {}
local codepoint2utf = unicode.utf8.char 
local used_encodings = {}

-- load inputenc encoding file
local function load_encfiles(f)
    local file= io.open(f,"r")
    local encodings = file:read("*all")
    file:close()
    for codepoint, licr in encodings:gmatch('DeclareUnicodeCharacter(%b{})(%b{})') do
        local codepoint = codepoint2utf(tonumber(codepoint:sub(2,-2),16))
        local licr= licr:sub(2,-2):gsub('@tabacckludge','')
        licrs[licr] = codepoint
    end
end

local function sanitize_licr(l)
    return l:gsub(" (.)",function(s) if s:match("[%a]") then return " "..s else return s end end):sub(2,-2)
end

local load_enc = function(enc)
  -- use default encodings if used doesn't provide one
  enc = enc or  {"T1","T2A","T2B","T2C","T3","T5", "LGR"}
    for _,e in pairs(enc) do
        local filename = e:lower() .. "enc.dfu"
    -- don't process an enc file multiple times
    if not used_encodings[filename] then
      local dfufile = kpse.find_file(filename)
      if dfufile then
        load_encfiles(dfufile)
      end
    end
    used_encodings[filename] = true
    end
end



local cache = {}

local get_utf8 = function(input)
    local output = input:gsub('\\IeC[%s]*(%b{})',function(iec)
    -- remove \protect commands 
    local iec = iec:gsub("\\protect%s*", "")
        local code = cache[iec] or licrs[sanitize_licr(iec)] or '\\IeC '..iec
        -- print(iec, code)
        cache[iec] = code
        return code
    end)
    return output
end


-- parse the idx file produced by tex4ht
-- it replaces the document page numbers by index entry number
-- each index entry can then link to place in the HTML file where the
-- \index command had been used

local parse_idx = function(content)
  -- index entry number
  local current_entry = 0
  -- map between index entry number and corresponding HTML file and destination
  local map = {}
  local buffer = {}

  for line in content:gmatch("([^\n]+)") do
    if line:match("^\\beforeentry") then
      -- increment index entry number
      current_entry = current_entry + 1
      local file, dest = line:match("\\beforeentry%s*{(.-)}{(.-)}")
      map[current_entry] = {file = file, dest = dest}
    elseif line:match("^\\indexentry") then
      -- replace the page number with the current
      -- index entry number
      local result = line:gsub("%b{}$", "{"..current_entry .."}")
      print(line, result)
      buffer[#buffer+1] = get_utf8(result)
    else
      buffer[#buffer+1] = line
    end
  end
  -- return table with page to dest map and updated idx file
  return {map = map, idx = table.concat(buffer, "\n")}
end

-- replace page numbers in the ind file with hyperlinks
local fix_idx_pages = function(content, idxobj)
  local buffer = {}
  local entries = idxobj.map
  for  line in content:gmatch("([^\n]+)")  do
    local line = line:gsub("(%s*\\%a+.-%,)(.+)$", function(start,rest)
      -- there is a problem when index term itself contains numbers, like Bible verses (1:2),
      -- because they will be detected as page numbers too. I cannot find a good solution 
      -- that wouldn't break something else.
      return start .. rest:gsub("(%d+)", function(page)
        local entry = entries[tonumber(page)]
        if entry then
          -- construct link to the index entry
          return "\\Link[" .. entry.file .."]{".. entry.dest .."}{}" .. page .."\\EndLink{}" 
        else
          return page
        end
      end)
    end)
    buffer[#buffer+1] = line 
  end
  return table.concat(buffer, "\n")
end

-- prepare the .idx file produced by tex4ht
-- for use with Xindy or Makeindex
local prepare_idx = function(filename)
  local f = io.open(filename, "r")
  if not f then return nil, "Cannot open file :".. tostring(filename) end
  local content = f:read("*all")
  local idx = parse_idx(content)
  local idxname = os.tmpname()
  local f = io.open(idxname, "w")
  f:write(idx.idx)
  f:close()
  -- return the object with mapping between dummy page numbers 
  -- and link destinations in the files, and the temporary .idx file
  -- these can be used for the processing with the index processor
  return idx, idxname
end

-- add links to a index file
local process_index = function(indname, idx)
  local f = io.open(indname,  "r")
  if not f then return  nil, "Cannot open .ind file: " .. tostring(indname) end
  local content = f:read("*all")
  f:close()

  local newcontent = fix_idx_pages(content, idx)
  local f = io.open(indname,"w")
  f:write(newcontent)
  f:close()
  return true
end

local get_idxname = function(par)
  return par.idxfile or par.input .. ".idx"
end

local prepare_tmp_idx = function(par)
  par.idxfile = get_idxname(par)
  if not par.idxfile or not mkutils.file_exists(par.idxfile) then return nil, "Cannot load idx file " .. (par.idxfile or "''") end
  -- construct the .ind name, based on the .idx name
  par.indfile = par.indfile or par.idxfile:gsub("idx$", "ind")
  load_enc()
  -- save hyperlinks and clean the .idx file
  local idxdata, newidxfile = prepare_idx(par.idxfile)
  if not idxdata then
    -- if the prepare_idx function returns nil, the second reuturned value contains error msg
    return nil, newidxfile
  end
  return  newidxfile, idxdata
end


local splitindex = function(par)
  local files = {}
  local idxfiles = {}
  local buffer 
  local idxfile = get_idxname(par)
  if not idxfile or not mkutils.file_exists(idxfile) then return nil, "Cannot load idx file " .. (idxfile or "''") end
  for line in io.lines(idxfile) do
    local file = line:match("indexentry%[(.-)%]")
    if file then
      -- generate idx name for the current output file
      file =  par.input .. "-" ..file .. ".idx"
      local current = files[file] or {}
      -- remove file name from the index entry
      local indexentry = line:gsub("indexentry%[.-%]", "indexentry")
      -- save the index entry and preseding line to the current buffer
      table.insert(current, buffer)
      table.insert(current, indexentry)
      files[file] = current
    end
    -- 
    buffer = line
  end
  -- save idx files
  for filename, contents in pairs(files) do
    log:info("Saving split index file: " .. filename)
    idxfiles[#idxfiles+1] = filename
    local f = io.open(filename, "w")
    f:write(table.concat(contents, "\n"))
    f:close()
  end
  return idxfiles
end

local function run_indexing_command (command, par)
  -- detect command name from the command. It will be the first word
  local cmd_name = command:match("^[%a]+") or "indexing"
  local xindylog  = logging.new(cmd_name)
  -- support split index
  local subindexes = splitindex(par) or {}
  if #subindexes > 0 then
    -- call the command again on all files produced by splitindex
    for _, subindex in ipairs(subindexes) do
      -- make copy of the parameters
      local t = {}
      for k,v in pairs(par) do t[k] = v end
      t.idxfile = subindex
      run_indexing_command(command, t)
    end
    return nil
  end
  local newidxfile, idxdata = prepare_tmp_idx(par)
  if not newidxfile then
    -- the idxdata will contain error message in the case of error
    xindylog:warning(idxdata)
    return false
  end
  par.newidxfile = newidxfile
  xindylog:debug("Prepared temporary idx file: ", newidxfile)
  -- prepare modules
  local xindy_call = command % par
  xindylog:info(xindy_call)
  local status = mkutils.execute(xindy_call)
  -- insert correct links to the index
  local status, msg = process_index(par.indfile, idxdata)
  if not status then xindylog:warning(msg) end
  -- remove the temporary idx file
  os.remove(newidxfile)
  -- null the indfile, it is necessary in order to support
  -- multiple indices
  par.indfile = nil
end


M.get_utf8 = get_utf8
M.load_enc = load_enc
M.parse_idx = parse_idx
M.fix_idx_pages = fix_idx_pages
M.prepare_idx = prepare_idx
M.process_index = process_index
M.prepare_tmp_idx = prepare_tmp_idx
M.run_indexing_command = run_indexing_command
return M

ad 2)

\chapter* and \section* commands, which are used for index titles, are not included in TOC by default. You can change that with the following config file:

\Preamble{xhtml}
\Configure{AddCss}{blitz-lite.css}
\Css{.partimage{margin:0 auto;text-align:center;}}
\Css{.partimage img{max-width:100\%;}}
\Css{.partHead .titlemark{display:block;}}
\DeclareGraphicsExtensions{.svg,.png,.jpg,.pdf}
\renewcommand\tableofcontents{%
\ifvmode\IgnorePar\fi\EndP\HCode{<h2>\contentsname</h2>}%
\TableOfContents[ part,chapter,likechapter,section,likesection,subsection ]
}

%\Configure{tableofcontents*}{part,chapter,likechapter,section,subsection}
\begin{document}
\EndPreamble

It redefines \tableofcontents command so it includes also \chapter* and \section* thanks to \TableOfContents[ part,chapter,likechapter,section,likesection,subsection]. This is a special TeX4ht command that can select which section types should be included in TOC. like... corresponds to the starred version of the sectioning command.

enter image description here

1
  • Thanks Michal, great job. Commented Aug 30, 2023 at 22:19

You must log in to answer this question.

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