我在一个文件中"The control sequence at the end of the top line"
引用了\leavevmodeifvmode
所有条目.ind
。文件\indexentry
中的每个条目都idx
被翻译为
\item \emph {{\textendash }\leavevmodeifvmode \kern .5em \textnormal {something }, 11,22
在.ind
文件中。
由于我找不到对 leavevmodeifvmode 的任何引用,我猜这与leavevmode@ifvmode
2018/12/01 的新定义有关\leavevmode 的功能和使用。
序言中的相关内容如下:
\RequirePackage[texindy]{imakeidx}
\makeindex[intoc, name=title, title={Index: Titles}, columns=1, options=-M title -C utf8 ]
我可以通过执行以下操作来暂时修复该问题:
\begin{filecontents*}{title.xdy}
(require "tex/inputenc/utf8.xdy")
(require "texindy.xdy")
\begin{theindex}
\makeatletter
\providecommand*\leavevmodeifvmode{\leavevmode@ifvmode}
\makeatother
....
\end{filecontents*}
但是,我猜想在翻译成正确的行时存在问题\indexterm
(无论是 xindy 还是 imakeidx?)。这是等待错误修复的问题还是我写错了(抱歉,制作 MWE 并不容易)
编辑
MWE(我必须涉及 biblatex,因为索引是由 biblatex 填充的,所以现在我认为嫌疑人可能是 biblatex):
\documentclass{article}
\usepackage{filecontents}
\usepackage[texindy]{imakeidx}
\usepackage[
style=numeric-comp,
autocite = superscript,
indexing=true,
backend=biber,
sorting=none
]{biblatex}
\begin{filecontents}{\jobname.bib}
@book{Knu86,
author = {Knuth, Donald E.},
year = {1986},
title = {The \TeX book},
}
\end{filecontents}
\bibliography{\jobname.bib}
\begin{filecontents*}{title.xdy}
(require "tex/inputenc/utf8.xdy")
(require "texindy.xdy")
(require "page-ranges.xdy")
(require "book-order.xdy")
(markup-index :open "~n
\begin{theindex}
% \makeatletter
% \providecommand*\leavevmodeifvmode{\leavevmode@ifvmode}
% \makeatother
\providecommand*\lettergroup[1]{%
\textit{#1}
\nopagebreak
}
~n"
:close "~n~n\end{theindex}~n"
:tree)
\end{filecontents*}
\indexsetup{level=\section*,toclevel=section}%
\makeindex[intoc, name=title, title={Index: Titles}, columns=1, options=-M title -C utf8 ]
\DeclareIndexFieldFormat{indextitle}{%
\usebibmacro{index:title}{\index[title]}{{\textendash}\enspace\textnormal{#1}}}%
\renewbibmacro*{citeindex}{%
\ifciteindex%
{\indexnames{labelname}%
\indexfield{indextitle}%
\indexfield{maintitle}% booktitle
\indexfield{booktitle}% booktitle
}{}%
}
\renewbibmacro*{bibindex}{%
\ifbibindex%
{\indexnames{author}%
\indexnames{editor}%
\indexnames{editora}%
\indexnames{editorb}%
\indexnames{editorc}%
\indexfield{indextitle}}%
{}
}
\DeclareCiteCommand{\supercite}[]%
{\usebibmacro{cite:init}%
\let\multicitedelim=\supercitedelim
\iffieldundef{prenote}
{}
{\BibliographyWarning{Ignoring prenote argument}}%
\iffieldundef{postnote}
{}
{\BibliographyWarning{Ignoring postnote argument}}}
{\usebibmacro{citeindex}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}}
\begin{document}
For test \autocite{Knu86}.
\printindex[title]
\end{document}
注意:查看 title.ind 中的这一行:
\item m {}book\emph {{\textendash }\leavevmodeifvmode \kern .5em \textnormal {The T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emX\spacefactor \m {}book}}, 1
答案1
您需要使两个命令变得健壮。它们在通过 idx 时会中断:
\usepackage[texindy]{imakeidx}
\usepackage{etoolbox}
\robustify\enspace
\robustify\TeX
(在乳胶的开发版本中,它们已经很强大并且您的示例编译时没有问题)。