2

Is it possible to let showidx display index entries on the same line as the text being indexed? It seems not as makeindx.pdf says:

This macro actually typesets the box containing all the index entries on the current page [...].

Which is a bit ironical since, in makeindx.pdf itself, the name of the macro being thereby described, \@mkidx, is in the margin, just in front of the text. (Of course, the environment seems different and \@mkidx is probably not an index entry. On the other hand, the text in cleveref.pdf, which also has margin entries, seems to be just ... text.)

So, given that I am already using hyperref, cleveref and tcolorbox, what might be an answer? Hopefully one that does not require yet another package.

Here is a rather long but minimal example:

% !TEX TS-program = pdflatexmk  
\documentclass{book}

    \usepackage{makeidx}
    \usepackage[hyperfootnotes=false]{hyperref}%[pdfborder={0 0 0}]

%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 

    \usepackage{cleveref}

        \newcounter{proc}
    \usepackage{tcolorbox}

%Begin the Sharpe (2013-01-18) code as modified by Schulz (2016-02-1) to have math in Showindex     
\let\oldopenparen\(
\let\oldcloseparen\)
\def\({\protect\oldopenparen}
\def\){\protect\oldcloseparen}
\newcommand{\INDEX}[1]{\index{#1}}
%End the Sharpe (2013-01-18) code as modified by Schulz (2016-02-1) to have math in Showindex               

\makeindex
\begin{document}    

Some text necessary to drown the words to be indexed. Some text necessary to drown the words to be indexed. \textbf{Oberdieck}\INDEX{Oberdieck}
Some text necessary to drown the words to be indexed. Some text necessary to drown the words to be indexed. 

\newpage

Some text necessary to drown the words to be indexed. Some text necessary to drown the words to be indexed.
\textbf{$\cup$}\INDEX{$\cup$}
Some text necessary to drown the words to be indexed. Some text necessary to drown the words to be indexed. 

\printindex
\end{document}
schremmer
  • 2,107
  • Can you provide a compilable example? –  Feb 10 '16 at 03:32
  • I hadn't realized one was needed in this case. I will make one. – schremmer Feb 10 '16 at 03:36
  • 1
    Untested: Try the imakeidx package and load showidx before –  Feb 10 '16 at 03:37
  • The above code is the only that works. The hack that loads showidx is by the Great Master himself in person. That is why I am not exactly hopeful. But I just realized I had missed the "i" in front of imakeidx. I will experiment. – schremmer Feb 10 '16 at 04:16
  • Looked at imakeidx and reledmac. Didn't see anything relevant to this issue. – schremmer Feb 10 '16 at 04:56

0 Answers0