3

Documentation for the repeatindex package says to use

makeindex -s repeatindex file

(or otherwise enclose each item in square-brackets), but I'm already using

makeindex -s file.ist

where file.ist is

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"

and the command \idxmark is defined in files preamble by:

\newcommand{\idxmark}[1]{{\let\gobbleone\relax\markboth{\sffamily\bfseries#1}{\sffamily\bfseries#1}}#1}
\providecommand\gobbleone[1]{}

The purpose of \idxmark is to display in the header on each Index page the first and last entries on that page (except for the first page).

How do I modify my .ist, or the \idxmark command, so as to satisfy the requirements for repeatindex?

(My difficulty is that I don't understand the syntax and semantics of the .ist file!)

Here is a (nearly) MWE to show the problem and and to test proposed fixes to the .ist shown above:

%% 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}

CAUTION: As it stands, file.tex processes without error despite the as-yet unaltered .ist needed to accommodate repeatindex. However, you may simulate the error with repeatindex simply by uncommenting the line

%\small

right after \begin{document}.

That artifice is the best I've been able to do so far to get a MWE exhibiting the repeatindex error.

I think all that \small accomplishes is to change which item begins and ends in each index column and page, so that this affects what repeatindex does when an index item does break across pages or columns.

In my actual, book-length, document, there is no such use of \small affecting the entire document body.

Note: The issue arises from the likely solution to the problem presented in Indexing error: \mathit allowed only in math mode.

  • Well you could try item_0 "\n\\item [\\idxmark{" and delim_0 "}], " but I have some doubts that the repeatindex code will like it that there is your \idxmark inside the brackets. Due to the missing complete example I haven't tested. – Ulrike Fischer Feb 15 at 11:38
  • @UlrikeFischer: Indeed,` item_0 "\n\\item [\\idxmark{"` and delim_0 "}], " does not work. – murray Feb 15 at 16:27
1
+50

repeatindex is not compatible with the memoir class as the code assumes that \subitem executes \@idxitem which it doesn't do in memoir.

repeatindex is buggy. It has (at least) two \expandafter to much. You can try this after loading the package, then it will at least probably not longer error.

\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

The ist-style is buggy too. It is missing a subitem case. But as you don't use it, it won't affect you:

item_0 "\n  \\item ["
delim_0 "], "
% added subitem case
item_x1 "] \n \\subitem "
  • Correct, that code avoids the repeatindex error when used with my .ist (the one including a call to \idxmark). But what repeatindex is supposed to do is not actually being done: an item is repeated at the top of the next page or column (with a trailing ellipsis mark) if a page or column break, respectively, occurs within its list of subitems. Instead, I'm just getting an ellipsis mark at the top of every column and page after the first in the index. – murray Feb 21 at 17:00
  • yes, as I wrote: it is not compatible with memoir. – Ulrike Fischer Feb 21 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.