在一本书长度的文档中memoir
,我得到了以下内容特殊输出从此代码开始索引:
\renewcommand{\indexname}{Index}
\renewcommand{\preindexhook}{%
\emph{%
For $d$\emph{-ball}, $d$\emph{-bounded set}, $d$\emph{-open set}, $(d,d')$\emph{-continuous map},
etc., see the corresponding entry \emph{ball}, \emph{bounded set}, \emph{open set}, \emph{continuous map}, etc.%
\vskip\onelineskip}%
}
\printindex\cleardoublepage%
令人惊讶的是,不仅左括号和右括号$(d,d')$\emph{-continuous map}
消失了,而且它们被替换为-.04em和-.15em, 分别。
无论我使用pdflatex
或 ,都会出现奇怪的输出(如下例所示,它决定使用哪种字体);因此/和/xelatex
都会发生错误。newtxtext
newtxmath
TeX Gyre Termes
Tex Gyre Termes Math
本书实际环境:
我正在使用 MacTeX/TeXLive 2020,并应用了所有当前更新。
通常,我只需在 TeXShop.app 中使用引擎 pdflatexmk 对根源文件运行“Typeset” topology.tex
。效果应该与连续运行相同:
pdflatex topology
bibtex topology
pdflatex topology
pdflatex topology
makeindex topology.nlo -s topology.ist -o topology.nls
makeindex names.idx -s names.ist -o names.ind
makeindex -s topology.ist topology
pdflatex topology
pdflatex topology
.ind
以下是本书文件的开头:
\begin{theindex}
\begingroup
\medskip\hfill\large\sffamily\bfseries\ifthenelse{\boolean{colorsecs}}{\color{myseccolor}}{} A\hfill\endgroup\medskip\nopagebreak
\item \idxmark{absolute-value function}, \hyperpage{17},
\hyperpage{323}
\item \idxmark{abstract quotient map}, \hyperpage{419}
问题:该怎么解决呢?
修复尝试失败:
以下尝试未能解决该问题:
\protect
每个括号\usepackage{ragged2e)
并更改\renewcommand{\preindexhook}{...
为\renewcommand{\preindexhook}{\RaggedRight...
- 分别将
(
和替换为和(来自))
\lparens
\rparens
mathtools
- 删除
\,
自$(d,\,d')$
简单的例子?
我无法在任何简单的例子中重现该输出缺少整本 600 多页的书!
下面是一个例子,其中输出正常,但包含所有相关代码(我希望)以及可能一些完全不相关的代码(但包括“以防万一”):
% book.tex
\RequirePackage{filecontents}
\begin{filecontents}{book.ist}
% book.ist - MakeIndex style file
% output main entry <entry> as: \item \idxmark{<entry>},
item_0 "\n\\item \\idxmark{"
delim_0 "}, "
% not forgetting the subitem case
item_x1 "} \n \\subitem "
headings_flag 1
heading_prefix "{\\medskip\\hfill\\large\\textsf{\\textbf{"
heading_suffix "}}\\hfill}\\medskip\\nopagebreak\n"
\end{filecontents}
\documentclass{memoir}
\RequirePackage[T2A,T1]{fontenc}
\RequirePackage{amsmath} % avoid \dddot clash
\RequirePackage{mathtools} % load now to avoid unicode-math clash
\RequirePackage{amsthm} % load now to avoid openbox clash
\usepackage{iftex}
\ifTUTeX
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{unicode-math}
\setdefaultlanguage[variant=american]{english}
\setotherlanguages{french,german,polish,russian}
\setmainfont{TeX Gyre Termes}[Scale=1.0]
\defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX}
\setmathfont{TeX Gyre Termes Math}
\newfontfamily{\cyrillicfont}{PT Serif}
\newcommand{\textsi}[1]{\textsc{#1}}
\newfontfamily{\xcheckmarkfont}{LibertinusSerif-Regular.otf}
\else
\usepackage[russian,french,ngerman,polish,main=english]{babel}
\babeltags{russian=russian,french=french,german=ngerman,polish=polish}
\RequirePackage{substitutefont} % to allow non-default Cyrillic
\substitutefont{T2A}{\rmdefault}{Tempora-TLF} % for Cyrillic
\RequirePackage[theoremfont]{newtxtext}
\RequirePackage[vvarbb]{newtxmath}%
\fi
% Additional font series macros
% light series
\DeclareRobustCommand\ltseries
{\not@math@alphabet\ltseries\relax
\fontseries\ltdefault\selectfont}
%
\newcommand{\ltdefault}{l}
%
\DeclareTextFontCommand{\textlt}{\ltseries}
% heavy(bold) series
\DeclareRobustCommand\hbseries
{\not@math@alphabet\hbseries\relax
\fontseries\hbdefault\selectfont}
\newcommand{\hbdefault}{hb}
\DeclareTextFontCommand{\texthb}{\hbseries}
\usepackage{microtype}
\usepackage{ragged2e}
%% PAGE DIMENSIONS
\setstocksize{11in}{8.5in}
\setpagecc{55.25pc}{38pc}{*}
\settypeblocksize{45pc}{28pc}{*}
\setlrmargins{*}{*}{*}
\setulmargins{*}{*}{*}
\checkandfixthelayout
%% PENALTIES
% set \clubpenalty, etc. to distinctive values for use
% in tracing page breaks.
\clubpenalty=9996
\widowpenalty=9999
\brokenpenalty=4991
\predisplaypenalty=10000
\postdisplaypenalty=1549
\displaywidowpenalty=1602
\nouppercaseheads
\makepagestyle{mypage}
\makeheadrule{mypage}{\textwidth}{\normalrulethickness}
\makeevenhead{mypage}{\bfseries\sffamily\thepage}{}{\bfseries\sffamily\leftmark}
\makeoddhead{mypage}{\bfseries\sffamily\rightmark}{}{\bfseries\sffamily\thepage}
\addtopsmarks{mypage}{}{%
% insert "Chapter\space" & "Section\space" if desired as 4th argument:
\createmark{chapter}{left}{shownumber}{}{\enspace}
\createmark{section}{right}{shownumber}{}{\enspace}
}
\makepsmarks{mypage}{%
\createmark{chapter}{both}{shownumber}{}{\enspace} % use both not left
\createmark{section}{right}{shownumber}{}{\enspace}
\createplainmark{toc}{both}{\contentsname}
\createplainmark{shorttableofconents}{both}{\shorttocname}
\createplainmark{longtableofcontents}{both}{\longtocname}
\createplainmark{lof}{both}{\listfigurename}
\createplainmark{lot}{both}{\listtablename}
\createplainmark{bib}{both}{\bibname}
\createplainmark{index}{both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}
\createplainmark{nomenclature}{both}{\nomname}
}
\providecommand\gobbleone[1]{}
\newcommand{\idxmark}[1]{{\let\gobbleone\relax\markboth{\sffamily\bfseries#1}{\sffamily\bfseries#1}}#1}
\makepagestyle{index}
\makeheadrule{index}{\textwidth}{\normalrulethickness}
% Fix for babel error by daleif (Lars Madsen}
% https://tex.stackexchange.com/a/501483/13492
\makeevenhead{index}%
{\let\gobbleone\relax\sffamily\bfseries\rightmark}%
{\sffamily\bfseries\MakeTextUppercase{\indexname}}%
{\let\gobbleone\relax\sffamily\bfseries\leftmark}
\makeoddhead{index}%
{\let\gobbleone\relax\sffamily\bfseries\rightmark}%
{\sffamily\bfseries\MakeTextUppercase{\indexname}}%
{\let\gobbleone\relax\sffamily\bfseries\leftmark}
\makeevenfoot{index}{}{\sffamily\thepage}{}
\makeoddfoot{index}{}{\sffamily\thepage}{}
\makechapterstyle{mychapter}{%
\renewcommand{\chapnamefont}{\sffamily\bfseries}
\renewcommand{\chapnumfont}{\fontsize{58}{64}\selectfont\sffamily\bfseries}
\renewcommand{\chaptitlefont}{\Huge\sffamily\bfseries}
%
\settoheight{\midchapskip}{\chapnumfont 1}
\setlength{\midchapskip}{0pt}
\setlength{\afterchapskip}{48pt}
%
\renewcommand{\printchaptername}{%
\chapnamefont\centering\MakeUppercase{\@chapapp}\par}
%
\renewcommand*{\printchapternum}{%
\vskip -8pt\centering \chapnumfont\thechapter} % or omit the vskip?
%
\renewcommand{\afterchapternum}{%
\par\nobreak\vskip \midchapskip%
\centering\rule{0.825\textwidth}{\normalrulethickness}%
\newline}
\renewcommand{\printchaptertitle}[1]{\centering\chaptitlefont ##1}
}
\chapterstyle{mychapter}
\usepackage{blindtext}
\makeindex
\begin{document}
\mainmatter
\pagestyle{mypage}
\Blindtext[1]
Alpaca\index{abc}
Zebra\index{zombie}% to fill up index page...
\index{a}\index{aa}\index{aaa}\index{aaaa}\index{aaaaa}\index{aaaaaa}\index{aaaaaaa}\index{aaaaaaaa}
\index{b}\index{bb}\index{bbb}\index{bbbb}\index{bbbbb}\index{bbbbbb}\index{bbbbbbb}\index{bbbbbbbb}
\index{c}\index{cc}\index{ccc}\index{cccc}\index{ccccc}\index{cccccc}\index{ccccccc}\index{cccccccc}
\index{d}\index{dd}\index{ddd}\index{dddd}\index{ddddd}\index{dddddd}\index{ddddddd}\index{dddddddd}
\index{e}\index{ee}\index{eee}\index{eeee}\index{eeeee}\index{eeeeee}\index{eeeeeee}\index{eeeeeeee}
\index{f}\index{ff}\index{fff}\index{ffff}\index{fffff}\index{ffffff}\index{fffffff}\index{ffffffff}
\index{g}\index{gg}\index{ggg}
\index{abcdefghijklmnopqustuvwxyzabcdef}
\index{zbcdefghijklmnopqustuvwxyzabcdef}
\backmatter
\pagestyle{index}
\setlength{\columnsep}{1em}
\renewcommand{\indexname}{Index}
\renewcommand{\preindexhook}{%
\emph{%
For $d$\emph{-ball}, $d$\emph{-bounded set}, $d$\emph{-open set}, $(d,\,d')$\emph{-continuous map},
etc., see the corresponding entry \emph{ball}, \emph{bounded set}, \emph{open set}, \emph{continuous map}, etc.%
\vskip\onelineskip}%
}
\printindex\cleardoublepage%
\end{document}
添加:
我还尝试在上面的“简单示例”中用我的书本长度文档的实际序言替换序言(实际上,输入的.tex
文件包含构成我的序言的几个文件的一系列\usepackage
命令 - 总共 16 个文件,大约 120K)。但这仍然不会导致奇怪的问题!
可能的解决方法:
以下解决方法似乎可以解决问题。但我对伪造括号的方式感到不满意,而括号实际上应该位于内联数学中!
\renewcommand{\preindexhook}{%
\emph{%
For $d$\emph{-ball}, $d$\emph{-bounded set}, $d$\emph{-open set}, \emph{(}$d,d'$\emph{)\hspace{2pt}-continuous map},
etc.,
see the corresponding entry \emph{ball}, \emph{bounded set}, \emph{open set}, \emph{continuous map}, etc.%
\vskip\onelineskip}%
}
答案1
这是 embrac 中的一个错误,在一个地方它使用了#4
而不是#3
。尝试这样做并通知作者:
\usepackage{embrac}
\ExplSyntaxOn
\cs_set_protected:Npn \__embrac_replace:Nnnnn #1#2#3#4#5
{
\tl_replace_all:Nnn #1 {#3}
{
\mode_if_math:TF
{#3} %<---instead of #4
{
\embrac_nobreak:
\embrac_kern:n {#2}
\embrac_nobreak:
\embrac_braces_format:n {#3}
\embrac_nobreak:
\embrac_kern:n {#4}
#5
}
}
}
\ExplSyntaxOff
答案2
这不是问题的答案,而是对实际问题的简短描述。它与memoir
或无关,归根结底是@murray 在其许多安装文件中加载的软件包的\preindexhook
问题。embrac
这是一个显示问题的超短 MWE。
\documentclass{article}
\usepackage{embrac}
\begin{document}
\emph{$(d,d')$}
\end{document}
在我完全更新的 TeXLive 2020 上,我得到了
这很奇怪,因为embrac
历史记录提到 v0.5 是为了不弄乱数学而制作的。但也许expl3
被改变了。
*File List*
article.cls 2019/12/20 v1.4l Standard LaTeX document class
size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
embrac.sty 2019/12/31 v0.9 Upright Brackets in Emphasized Text
expl3.sty 2020-07-17 L3 programming layer (loader)
l3backend-pdfmode.def 2020-06-29 L3 backend support: PDF mode
xparse.sty 2020-05-15 L3 Experimental document command parser
xparse-generic.tex
l3keys2e.sty 2020-05-15 LaTeX2e option processing using LaTeX3 keys