软件包的文档repeatindex
说使用
makeindex -s repeatindex file
(或者将每个项目括在方括号中),但我已经在使用
makeindex -s file.ist
哪里file.ist
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"
该命令在前言\idxmark
中定义如下:file
\newcommand{\idxmark}[1]{{\let\gobbleone\relax\markboth{\sffamily\bfseries#1}{\sffamily\bfseries#1}}#1}
\providecommand\gobbleone[1]{}
目的\idxmark
是在每个索引页的页眉中显示该页的第一个和最后一个条目(第一页除外)。
我如何修改我的.ist
或\idxmark
命令 以满足 的要求repeatindex
?
(我的困难在于我不理解该.ist
文件的语法和语义!)
这里有一个(几乎)MWE 来展示问题并测试对.ist
上面显示的问题提出的修复:
%% File file.tex
\documentclass{memoir}
%% LANGUAGES & FONTS
\RequirePackage[russian,french,ngerman,polish,main=english]{babel}%
\RequirePackage{microtype}
\usepackage[LGR,T1]{fontenc}
%% LAYOUT
\RequirePackage{multicol}
%% UTILITIES
\RequirePackage{calc}
%%%%%%%% BEGIN STYLE %%%%%%%%
%% PAGE DIMENSIONS
\setstocksize{11in}{8.5in}
% entire typeblock is centered on stock
\setpagecc{55.25pc}{38pc}{*}
\settypeblocksize{45pc}{28pc}{*}
\setlrmargins{*}{*}{*}
\setulmargins{*}{*}{*}
\checkandfixthelayout
%% PAGE STYLES (headers & footers)
\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}
}
% daleif:
\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}
}
\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}{}
% Set pagstyle
\pagestyle{mypage}
%% CHAPTER STYLE:
\makeatletter
\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}
}
\makeatother
% Set chapter style:
\chapterstyle{mychapter}
%% SECTIONING STYLES
\setsecnumdepth{subsection}
% sections:
\setsecheadstyle{\centering\Large\bfseries\sffamily}
\setbeforesecskip{3.75ex+1ex-.2ex}
\setaftersecskip{2.35ex+.2ex}
%%%%%%%% END STYLE %%%%%%%%
%%%%%%%% BEGIN INDEXING %%%%%%%%
\RequirePackage{repeatindex}
\newcommand{\indexemph}{\textbf} % definition or main location
\newcommand{\nn}[1]{{#1}n}
\newcommand{\figidx}[1]{{#1}fig}
\providecommand\gobbleone[1]{}
\newcommand{\seeonly}[2]{\, (\emph{\seename} #1)}
\newcommand{\also}[2]{\unskip(\emph{\alsoname} #1)}
\newcommand{\Also}[2]{\unskip\emph{See also} #1}
% From https://tex.stackexchange.com/questions/332093/error-with-entries-in-index-page-header-memoir-class
\makeatletter
\def\indexsee#1{\indexseeI#1@\end}
\def\indexseeI#1@#2\end{%
\def\temp{#2}%
\ifx\temp\empty
\def\next{\indexseeIII{#1}{#1}}%
\else
\def\next{\indexseeII#1@#2\end}%
\fi
\next
}
\def\indexseeII#1@#2@\end{\indexseeIII{#1}{#2}}
\def\indexseeIII#1#2#3{\index{#1@#2\protect\gobbleone|seeonly{#3}}}
\newcommand{\indexalso}[2]{\index{#1!zzzz@\protect\gobbleone|also{#2}}}
\newcommand{\indexAlso}[2]{\index{#1!zzzz@\protect\gobbleone|Also{#2}}}
\makeatother
%% try this
\newcommand{\indexnamesee}[2]{\index[names]{#1\protect\gobbleone|seeonly{#2}}}
% ...fix for memoir to put hyperlink on mainref, too:
\newcommand{\mainref}[1]{\textbf{\emph{\hyperpage{#1}}}}
%%%%%%%% END INDEXING %%%%%%%%
%%%%%%%% CROSS-REFERENCING %%%%%%%%
\usepackage[pdftex]{hyperref}
\hypersetup{
plainpages=false,pdfpagelabels,
bookmarksnumbered,
breaklinks=true,
colorlinks, citecolor=red, filecolor=black, linkcolor=blue, urlcolor=blue,
linktocpage=true,linktoc=all%
}
%%%%%%%% END CROSS-REFERENCING %%%%%%%%
\RequirePackage[draft]{fixme}%
\fxsetup{layout=margin}%
\fxusetheme{color}%
\makeindex
\begin{document}
%% !! UNCOMMENT NEXT LINE TO FORCE SIMULATED repeatindex ERROR !!
%\small
\mainmatter
\chapter{The fall of Humpty-Dumpty}
This is about the story\index{story} of Humpty-Dumpty%
\index{Humpty|see{Humpty-Dumpty}}
\index{Dumpty|see{Humpty-Dumpty}}
\index{Humpty-Dumpty|seealso{King's horses}}
\section{The Wall}
\index{bnothing}
\index{bnothing!nil}
\index{bnothing!nil!and zero}
\index{bnothing!null}
\index{bnull elements}
\index{bzero elements}
\index{belements!zero}
\index{cnothing}
\index{cnothing!nil}
\index{cnothing!nil!and zero}
\index{cnothing!null}
\index{cnull elements}
\index{czero elements}
\index{celements!zero}
\index{dnothing}
\index{dnothing!nil}
\index{dnothing!nil!and zero}
\index{dnothing!null}
\index{dnull elements}
\index{dzero elements}
\index{delements!zero}
\index{enothing}
\index{enothing!nil}
\index{enothing!nil!and zero}
\index{enothing!null}
\index{enull elements}
\index{ezero elements}
\index{eelements!zero}
\index{fnothing}
\index{fnothing!nil}
\index{fnothing!nil!and zero}
\index{fnothing!null}
\index{fnull elements}
\index{fzero elements}
\index{felements!zero}
\index{gnothing}
\index{gnothing!nil}
\index{gnothing!nil!and zero}
\index{gnothing!null}
\index{gnull elements}
\index{gzero elements}
\index{gelements!zero}
\index{hnothing}
\index{hnothing!nil}
\index{hnothing!nil!and zero}
\index{hnothing!null}
\index{hnull elements}
\index{hzero elements}
\index{helements!zero}
\section{The King's horses}
\index{knothing}
\index{knothing!nil}
\index{knothing!nil!and zero}
\index{knothing!null}
\index{knull elements}
\index{kzero elements}
\index{kelements!zero}
\index{lnothing}
\index{lnothing!nil}
\index{lnothing!nil!and zero}
\index{lnothing!null}
\index{lnull elements}
\index{lzero elements}
\index{lelements!zero}
\index{mnothing}
\index{mnothing!nil}
\index{mnothing!nil!and zero}
\index{mnothing!null}
\index{mnull elements}
\index{mzero elements}
\index{melements!zero}
\index{nnothing}
\index{nnothing!nil}
\index{nnothing!nil!and zero}
\index{nnothing!null}
\index{nnull elements}
\index{nzero elements}
\index{nelements!zero}
\backmatter
\pagestyle{index}
\setlength{\columnsep}{1em}
\printindex\cleardoublepage%
\end{document}
警告:目前,尽管需要适应,file.tex
但处理过程没有错误。但是,您可以通过取消注释该行来模拟错误.ist
repeatindex
repeatindex
%\small
紧接着\begin{document}
。
到目前为止,这是我能做的最好的让 MWE 展示错误的方法repeatindex
。
我认为这样\small
做的目的就是改变每个索引列和页面中哪个项目开始和结束,这样repeatindex
当索引项目跨页或跨列时就会发生影响。
在我的实际、一本书长度的文档中,不存在\small
影响整个文档主体的这种用法。
笔记:这个问题源于索引错误:\mathit 仅允许在数学模式下使用。
答案1
repeatindex 与 memoir 类不兼容,因为代码假定 \subitem 执行,\@idxitem
但在 memoir 中却没有执行。
repeatindex 有 bug。它至少有两个 \expandafter,太多了。您可以在加载包后尝试这个,这样至少不会再出错。
\makeatletter
\AtBeginDocument
{
% New \subitem command, to be used as usual
\renewcommand{\subitem}{%
% call original command
\orig@subitem
% set the contents to be repeated on the next page
\expandafter\hhafterpage\expandafter{\expandafter\par\expandafter{%
\expandafter\entryprefix\@@entry\entrypostfix}}%
% copy \@entry to \@@entry. This is done to delay the entry to be
% put onto the page, due to a strange behaviour of afterpage (some
% text of the next page is executed before the afterpage text is
% put onto the page).
\xdef\@@entry{\@entry}%
}%
%
% New \subsubitem command, to be used as usual
\renewcommand{\subsubitem}{%
% call original command
\orig@subsubitem
% set the contents to be repeated on the next page
\expandafter\hhafterpage\expandafter{\expandafter\par\expandafter{%
\expandafter\itshape\@@entry\dots}}%
% copy \@entry to \@@entry. This is done to delay the entry to be
% put onto the page, due to a strange behaviour of afterpage (some
% text of the next page is executed before the afterpage text is
% put onto the page).
\xdef\@@entry{\@entry}%
}%
}
\makeatother
ist-style 也有 bug。它缺少一个 subitem case。不过由于你不使用它,所以它不会对你造成影响:
item_0 "\n \\item ["
delim_0 "], "
% added subitem case
item_x1 "] \n \\subitem "