This question is just like that of Mark indexed entries in the text itself?, except for use with the memoir document class.
How can index entries be marked within the text adjacent to where the \index command is placed — and not in the corner of the page as showidx does it, either:
- above the line, the way
showkeysdoes it; and/or - in the margin on the line where the
\indexappears?
Ideally, the user should have control over the format (font family, size, and color) of the entries that appear.
The answer at the cited question does not work with memoir.
A solution needs to work with:
hyperref(and Heiko Oberdiek's "quick and dirty fix to allowshowidxandhyperrefto coexist).- Multiple indexes, e.g. he main one and an index of names (where one uses
\index[names]{..}).
Here's a sample source file, albeit with only a single index:
\documentclass[draft]{memoir}
\usepackage[usenames]{xcolor}
\makeindex
\usepackage[final]{hyperref}
\hypersetup{colorlinks,citecolor=red,linkcolor=blue}
%Begin the ``quick and dirty hack'' due to Heiko Oberdiek which loads showidx
\makeatletter
\ifHy@hyperindex
\def\HyInd@ParenLeft{(}%
% Hook in \HyInd@@wrindex
\let\HyInd@showidx\@empty
% Hook in \HyInd@@wrindex for package showidx
\def\HyInd@showidx#1{%
\@showidx{#1}%
\if@nobreak
\ifvmode
\nobrak
\fi
\fi
}%
% Load package showidx
\let\siOrg@makeindex\makeindex
\let\siOrg@@index\@index
\let\siOrg@@wrindex\@wrindex
\let\siOrg@index\index
\RequirePackage{showidx}
\let\makeindex\siOrg@makeindex
\let\@index\siOrg@@index
\let\@wrindex\siOrg@@wrindex
\let\index\siOrg@index
% rest of hyperref part
\@ifpackageloaded{multind}{%
\let\HyInd@org@wrindex\@wrindex
\def\@wrindex#1#2{\HyInd@@wrindex{#1}#2||\\}%
\def\HyInd@@wrindex#1#2|#3|#4\\{%
\ifx\\#3\\%
\HyInd@org@wrindex{#1}{#2|hyperpage}%
\else
\def\Hy@temp@A{#3}%
\ifx\Hy@temp@A\HyInd@ParenLeft
HyInd@org@wrindex{#1}{#2|#3hyperpage}%
\else
\HyInd@org@wrindex{#1}{#2|#3}%
\fi
\fi
}%
}{%
\def\@wrindex#1{\@@wrindex#1||\\}
\def\@@wrindex#1|#2|#3\\{%
\ifx\\#2\\%
\protected@write\@indexfile{}{%
\string\indexentry{#1|hyperpage}{\thepage}%
}%
\else
\def\Hy@temp@A{#2}%
\ifx\Hy@temp@A\HyInd@ParenLeft
\protected@write\@indexfile{}{%
\string\indexentry{#1|#2hyperpage}{\thepage}%
}%
\else
\protected@write\@indexfile{}{%
\string\indexentry{#1|#2}{\thepage}%
}%
\fi
\fi
\endgroup
\HyInd@showidx{#1}%
\@esphack
}%
}%
\fi
\makeatother
%
%End the ``quick and dirty hack'' due to Heiko Oberdiek which loads showidx
\begin{document}
\tableofcontents
\chapter{We begin}\index{beginning}
Hello\index{greeting!hello|(}%
\index{Hello} %
to the World!\index{World}
\index{greeting|seealso{Hello,World}}
\newpage
abc\index{abc}%
\index{alphabet|see{abc}} %
is before def.\index{greeting!hello|)}
\printindex
\end{document}
And here's an accompanying .ist file:
headings_flag 1
heading_prefix "{\\medskip\\hfill\\large\\textsf{\\textbf{"
heading_suffix "}}\\hfill}\\medskip\\nopagebreak\n"
memoir. I have looked at my original code but through fading capabilities I can't understand it. Perhaps the current maintainer could help. – Peter Wilson May 31 '19 at 18:07memoiremulatesshowidx, and (2) the answer at https://tex.stackexchange.com/questions/64249/mark-indexed-entries-in-the-text-itself does what I want if one is usingshowidxitself (withbookorarticledocumentclass). – murray Jun 01 '19 at 00:30