Unicode 文档能否用 LaTeX 正确地编入索引?

Unicode 文档能否用 LaTeX 正确地编入索引?

我正在尝试为一本使用 Unicode 的书创建一个合适的索引。恰当的,我的意思是索引包含 (i) 适当的条目、子条目和子子条目;(ii) 文本跨度的索引;(iii) 带有可点击页码链接的索引条目;以及 (iv) 索引条目内的某些格式。

我的文档是西班牙语的,使用 Unicode,如上所述。更改这一点是不可能的。我还必须继续使用、和polyglossiahyperref,因为它们是整本书不可或缺的一部分。因此,删除其中任何一个包都不是解决方案。glossarycleverref

我使用TexLive 2020 中的TexStudiowith 。Xelatex对于索引,我使用imakeidxwith xindy。据我所知,它xindy是仅有的两个 Latex 索引器之一,并且它是唯一可以处理 Unicode 的索引器。我也在使用该seealso软件包,因为它尝试修复没有它时出现的各种问题。

这是 MWE。示例中解释了错误。

% !TEX program = xelatex
% !TeX encoding = utf8
% You may have to compile with --shell-escape

\documentclass[11pt,fleqn,letterpaper,twoside,openright,spanish]{book}

% LANGUAGE CONFIG
\usepackage{polyglossia}
\setmainlanguage{spanish}
\SetLanguageKeys{spanish}{indentfirst=false}
\setotherlanguage[variant=usmax]{english}

% INDEXING
%\usepackage{showidx}  % Must be loaded before 'imakeidx'.
\usepackage[quiet,xindy]{imakeidx}
\makeindex[program=texindy,options=-C utf8 -M lang/spanish/modern-utf8-lang.xdy]
\usepackage{seealso}  % Must be loaded after imakeidx

% HYPERLINKS
\usepackage[pdfencoding=auto,bookmarksdepth=3,psdextra,spanish,plainpages=false,colorlinks=false,pdfborderstyle={/S/U/W 1},breaklinks=true,bookmarksopen=false,unicode=true,pdflang=es-ES]{hyperref}

% LOADED IN CASE THEY AFFECT XINDY
\usepackage[xindy={language=spanish-modern,codepage=utf8},translate=true,nopostdot,nonumberlist,seeautonumberlist]{glossaries} % Must be loaded after 'hyperref'
\usepackage[nameinlink,noabbrev]{cleveref}  % Must be loaded after 'hyperref'


% ---------- DOCUMENT BEGINS ----------
\begin{document}

This simple example is indexed properly\index{properly}, as people\index{people} expect.

We can also do sub-entries\index{structures!sub-entry} and sub-subentries\index{structures!sub-subentry} just fine.

Sub-entries can also be formatted\index{beautification!formatting@\textit{formatting}} fine.

Index headers can be formatted, with things like italics\index{italics@\textsl{italics}} and boldface\index{boldface@\textbf{boldface}}.

But...

ERROR: Jenny\index{Jenny|textbf} can't be bolded. In the index, no boldface is applied and no page number appears.

ERROR: Joe\index{Joe|textit} can't be italicized, either. An index entrey without italics or even a page number is generated.

ERROR: Poor Peter\index{Peter|see{people}} cannot be indexed as a person with \textit{see}. An empty space between two commas appears in his index entry.

ERROR: Unsurprisingly, Paul\index{Paul|see {people}}, with a space in his \textit{see} command, can't be indexed as a person either. An empty space between two commas appears in his index entry, too.

ERROR: Jen\index{Jen|seealso{people}} also breaks things when we want to \textit{seealso} her. Yet again, and empty space with commas on either side appears in her index entry.

ERROR: Jen\index{Jen|seealso {people}} still breaks things when we try to \textit{seealso} her with a space in the command.

ERROR: And the fail\index{fail|(} is total when we try to index a span of text.\index{fail|)}. This causes an empty index entry (except for a comma), and a compiler error, too.

\printindex

\end{document}

正如 MWE 所示,大多数索引功能都已损坏——索引条目的格式、的使用see、的使用seealso、文本跨度的索引。

如何修复这些错误?

相关内容