TeX - LaTeX Asked on November 14, 2021
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.%
vskiponelineskip}%
}
printindexcleardoublepage%
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
medskiphfilllargesffamilybfseriesifthenelse{boolean{colorsecs}}{color{myseccolor}}{} Ahfillendgroupmedskipnopagebreak
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:
protect
ing each parenthesisusepackage{ragged2e)
and changing renewcommand{preindexhook}{...
to renewcommand{preindexhook}{RaggedRight...
(
and )
, respectively, with lparens
and rparens
(from mathtools
),
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\nopagebreakn"
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
DeclareRobustCommandltseries
{not@math@alphabetltseriesrelax
fontseriesltdefaultselectfont}
%
newcommand{ltdefault}{l}
%
DeclareTextFontCommand{textlt}{ltseries}
% heavy(bold) series
DeclareRobustCommandhbseries
{not@math@alphabethbseriesrelax
fontserieshbdefaultselectfont}
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}{bfseriessffamilythepage}{}{bfseriessffamilyleftmark}
makeoddhead{mypage}{bfseriessffamilyrightmark}{}{bfseriessffamilythepage}
addtopsmarks{mypage}{}{%
% insert "Chapterspace" & "Sectionspace" 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}
}
providecommandgobbleone[1]{}
newcommand{idxmark}[1]{{letgobbleonerelaxmarkboth{sffamilybfseries#1}{sffamilybfseries#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}%
{letgobbleonerelaxsffamilybfseriesrightmark}%
{sffamilybfseriesMakeTextUppercase{indexname}}%
{letgobbleonerelaxsffamilybfseriesleftmark}
makeoddhead{index}%
{letgobbleonerelaxsffamilybfseriesrightmark}%
{sffamilybfseriesMakeTextUppercase{indexname}}%
{letgobbleonerelaxsffamilybfseriesleftmark}
makeevenfoot{index}{}{sffamilythepage}{}
makeoddfoot{index}{}{sffamilythepage}{}
makechapterstyle{mychapter}{%
renewcommand{chapnamefont}{sffamilybfseries}
renewcommand{chapnumfont}{fontsize{58}{64}selectfontsffamilybfseries}
renewcommand{chaptitlefont}{Hugesffamilybfseries}
%
settoheight{midchapskip}{chapnumfont 1}
setlength{midchapskip}{0pt}
setlength{afterchapskip}{48pt}
%
renewcommand{printchaptername}{%
chapnamefontcenteringMakeUppercase{@chapapp}par}
%
renewcommand*{printchapternum}{%
vskip -8ptcentering chapnumfontthechapter} % or omit the vskip?
%
renewcommand{afterchapternum}{%
parnobreakvskip midchapskip%
centeringrule{0.825textwidth}{normalrulethickness}%
newline}
renewcommand{printchaptertitle}[1]{centeringchaptitlefont ##1}
}
chapterstyle{mychapter}
usepackage{blindtext}
makeindex
begin{document}
mainmatter
pagestyle{mypage}
Blindtext[1]
Alpacaindex{abc}
Zebraindex{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.%
vskiponelineskip}%
}
printindexcleardoublepage%
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.%
vskiponelineskip}%
}
It is a bug in embrac, in one place it uses #4
instead of #3
. Try this and notify the author:
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
Answered by Ulrike Fischer on November 14, 2021
This is not an answer to the problem, but rather a short write up of the actual problem. It is not related to memoir
or preindexhook
, it boils down to a problem with the embrac
package that @murray loads deep deep down in their many setup files.
Here is a super short MWE that displays the problem.
documentclass{article}
usepackage{embrac}
begin{document}
emph{$(d,d')$}
end{document}
On my fully up to date TeXLive 2020 I get
which is strange as the embrac
history mentions that v0.5 was made to not mess with math. But perhaps expl3
was changed.
*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
Answered by daleif on November 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP