如何将索引条目显示在与被索引的文本相同的行上

如何将索引条目显示在与被索引的文本相同的行上

是否可以将showidx索引条目显示在与被索引文本相同的行上?似乎不行,正如makeindx.pdf所说:

这个宏实际上排版盒子包含当前页面上的所有索引条目[...]。

这有点讽刺,因为,就makeindx.pdf其本身而言,由此描述的宏的名称\@mkidx位于边缘,就在文本的前面。(当然,环境似乎不同,\@mkidx可能不是索引条目。另一方面,cleveref.pdf也有边缘条目的文本似乎只是...文本。)

因此,鉴于我已经在使用hyperrefclevereftcolorbox答案可能是什么?希望答案不需要其他包裹。

这是一个相当长但最简单的例子:

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

相关内容