我第一次使用 tex4ebooks。我以为今天我已经成功用它建立索引了,但在最后一步出现了编码问题,我已经在论坛的帮助下解决了这个问题。
但是现在未定义的控制序列出现了,最小的例子如下:
tex4ebook 的配置显示如下:
\Preamble{xhtml,no-cut,3,info}
\usepackage{indexing4ht}
\usepackage{gettitlestring}
\makeatletter
\Configure{@author}{\let\footnote\@gobble}
\Configure{@title}{\let\footnote\@gobble}
\makeatother
\GetTitleStringDisableCommands{%
\renewcommand\textbf[1]{#1}%
\renewcommand\LaTeX{LaTeX}
}
\begin{document}
\Configure{DocumentLanguage}{de}
% 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:contributor>Somethin</dc:contributor>}}
\Configure{OpfMetadata}{\HCode{<dc:date opf:event='Originalausgabe'>2023</dc:date>}}
\EndPreamble
indexing4ht.sty如下:
\ProvidesPackage{indexing4ht}
\RequirePackage{etoolbox}
\RequirePackage{gettitlestring}
% Befehl zum Abrufen der vollständigen Abschnittsnummer für den aktuellen Abschnittsbefehl
\newcommand\getCurrentSectionNumber{%
\ifnum\c@section=0 %
\thechapter
\else
\ifnum\c@subsection=0 %
\thesection
\else
\ifnum\c@subsubsection=0 %
\thesubsection
\else
\thesubsubsection
\fi
\fi
\fi
}
\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*}
\endinput
indexing4ht.4ht 显示:
\@ifpackageloaded{imakeidx}{%
\makeatletter
\newcommand\:wrindex[3]{%
\edef\th@idx@entry{\detokenize{#2}}
\imki@wrindexentry{#1}{\th@idx@entry}{#3}
}
\makeatother
}{%ToDo: Provide configuration for index writing without imakeidx
\newcommand\:wrindex[3]{}
}
% because imakeidx has support for multiple indices, we need to select a
% right one
\NewConfigure{indexname}{1}
% 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
\NewConfigure{indexvalue}{1}
\Configure{indexvalue}{\getCurrentSectionNumber}
\NewConfigure{indexidentifier}{1}
\Configure{indexidentifier}{\CurSecHaddr}
% we need to suppress adding of multiple identical identifiers
\edef\curseccnt{}
\renewcommand\index[2][]{%
\ifx|#1|%
\Configure{indexname}{\jobname}%
\else\Configure{indexname}{#1}%
\fi%
\:wrindex{\a:indexname}{#2}{\a:indexvalue}
% save identifier only if it haven't been used yet
\expandafter\ifcsname usedsec\a:indexvalue\endcsname
\else%
\Tag{sec\a:indexvalue}{\a:indexidentifier}
\fi%
\expandafter\gdef\csname usedsec\a:indexvalue\endcsname{yes}
\let\curseccnt\newseccnt
}
% print index locators. make links to destinations in document
\newcommand\idxlocator[1]{%
\ifTag{sec#1}{\a:locatorlink{\Ref{sec#1}}{}#1\b:locatorlink}{#1}%
%\ifTag{sec#1}{\Link{\Ref{sec#1}}{}#1\EndLink}{#1}%
\typeout{\LikeRef{sec#1}}}
\NewConfigure{locatorlink}{2}
\Configure{locatorlink}{\Link}{\EndLink}
% to support crossreferencess, we save index keyword with unique identifier
\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}
\renewcommand\see[1]{%
\GetTitleString{#1}%
\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
\NewConfigure{seeLink}{2}
\Configure{seeLink}{\Link}{\EndLink}
\NewConfigure{see}{1}
\Configure{see}{\textit{siehe}}
\renewcommand\seealso[1]{%
\GetTitleString{#1}%
\a:seealso\ \ifTag{idxkw#1}{\a:seeAlsoLink{\Ref{idxkw\GetTitleStringResult}}{}#1\b:seeAlsoLink}{#1}
}
\NewConfigure{seeAlsoLink}{2}
\Configure{seeAlsoLink}{\Link}{\EndLink}
\NewConfigure{seealso}{1}
\Configure{seealso}{\textit{siehe auch}}
最终的 makefile mymakef.mk4 如下:
if mode=="draft" then
Make:htlatex {}
else
Make:htlatex {}
Make:xindy {modules={"duden-utf8"}}
Make:biber {}
Make:htlatex {}
Make:htlatex {}
end
那我先跑了
tex4ebook -a debug -c myconfig.cfg -m index -e mymakef.mk4 Sourcename.tex
然后手动调用xindy获取.ind文件
call xindy -L german -C duden-utf8 -I latex -M Sourcename.xdy Sourcename.idx
然后我再次运行 tex4ebook 并得到未定义的控制序列错误:
Undefined control sequence.
l.9 \item \idxkeyword
{Ende}, \idxlocator{4}
该 tex 文件最终是这个最小示例:
\documentclass[11pt,a4paper]{report}
\usepackage[cmintegrals,cmbraces]{newtxmath}
\usepackage{ebgaramond-maths}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{tex4ebook}
\usepackage[xindy,noautomatic]{imakeidx}
\makeindex[intoc=false,columns=1,noautomatic,title=Alphabetisches Verzeichnis]
\usepackage[hyperindex=true,
pdfauthor={Autor},
pdftitle={Titel},
pdfkeywords={Philosophy}]{hyperref}
\begin{document}
\tableofcontents
\section{Übungen}
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}
\printindex
\end{document}
也许有人知道门的线索。谢谢。
汤姆克拉特斯
答案1
TeX4ht 现在支持开箱即用的索引功能,因此您实际上不需要该indexing4ht
包。您可以将其从.cfg
文件中删除。我还必须将其Make:biber {}
从您的构建文件中删除,因为您在示例中没有使用 BibLaTeX,这导致了错误。
对于 German-Duden,请尝试此构建文件:
if mode=="draft" then
Make:htlatex {}
else
Make:htlatex {}
Make:xindy {language="german-duden"}
Make:htlatex {}
Make:htlatex {}
end
有关索引的最新信息可在此处找到如何。
您的索引在 Calibre 中的样子如下: