In a book-length document with memoir, I'm getting the following peculiar output from this code for the beginning of the index:
\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%
The surprise is not only that the left- and right-parentheses from $(d,d')$\emph{-continuous map} have disappeared, but also that they have been replaced by -.04em and -.15em, respectively.
The peculiar output occurs no matter whether I use pdflatex or xelatex (which, as the example below indicates, determines which fonts are used); thus the error occurs with both newtxtext/newtxmath and TeX Gyre Termes/Tex Gyre Termes Math.
Environment of the actual book:
I'm using MacTeX/TeXLive 2020, with all current updates applied.
Typically, I just run "Typeset" on the root source file topology.tex with engine pdflatexmk inside TeXShop.app.
The effect should be the same as successively running:
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
Here is the beginning of the .ind file for the book:
\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}
Question: How can that be fixed?
Failed attempts to fix:
The following attempts failed to correct the issue:
\protecting each parenthesis\usepackage{ragged2e)and changing\renewcommand{\preindexhook}{...to\renewcommand{\preindexhook}{\RaggedRight...- replacing
(and), respectively, with\lparensand\rparens(frommathtools) - deleting
\,from$(d,\,d')$
Simple example?
I'm unable to reproduce that output in any simple example short of the entire 600+-page book!
Below is such an example, where the output is OK, but with all the relevant code (I hope) and probably some totally irrelevant code (but included "just in case"):
% 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}
Added:
I also tried in the "simple example" above replacing the preamble by the actual preamble of my book-length document (actually, an inputted .tex file which contains a bunch of \usepackage commands for the several files constituting my preamble — a total of 16 files with some 120K). But still that does not cause the peculiar problem!
Possible work-around:
The following work-around seems to cure the problem. But I'm unhappy about the way that I had to fake the pair of parentheses, which really ought to be inside the inline math!
\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}%
}


theindex,memoirjust places the contents of\preindexhook, without any special processing, after the chapter title. What are the first lines of the.indfile? – egreg Jul 17 '20 at 21:17\lparen/\rparendoesn't work makes me skeptical of the possibility of an active paren issue, especially since, presumably, parentheses elsewhere in the document are fine. You could, just to be sure, include\message{\the\catcode(}` in the preindexhook to make sure you have a catcode of 12, I'm wondering if something is messed up in the font specifications somehow. – Don Hosek Jul 22 '20 at 04:12\messagecode above fell pray to limitations of markdown. There should be a backtick before the(. – Don Hosek Jul 22 '20 at 04:51memoirjust adds a\chapter*{\indexname}followed by the (possibly empty)\reindexhookand then the index it self it does notthing special to it. – daleif Jul 22 '20 at 17:34