使索引引用 \poemtitle(诗歌包)而不是页码

使索引引用 \poemtitle(诗歌包)而不是页码

我尝试在诗集中制作“押韵索引”。

于是,我开始定一个索引,叫“押韵索引”:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{imakeidx}
\usepackage{verse}

\makeindex
\makeindex[name=rhymes,title=Index of rhymes]

\begin{document}
\poemtitle{The Road Not Taken}
\begin{verse}
    Two roads diverged in a yellow wood,\\ \index[rhymes]{ood}
    And sorry I could not travel both\\ \index[rhymes]{oth}
    And be one traveler, long I stood\\ \index[rhymes]{ood}
    And looked down one as far as I could\\ \index[rhymes]{ood}
    To where it bent in the undergrowth;\\ \index[rhymes]{oth}
\end{verse}

\printindex[rhymes]
\end{document}

输出是这个输出

因此,每个韵律的页面设置正确。但我尝试让它显示用 设置的诗​​歌标题,而不是页面\poemtitle

那么,是否可以捕获最后\poemtitle的值并在每个韵律附近的索引中使用它而不是使用它的页码?

预期的渲染是这样的:

在此处输入图片描述

答案1

我不知道如何用其他内容替换索引中的页码。但请看一下这个:

% verseindexprob.tex  SE 641848

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{imakeidx}
\usepackage{verse}

\newcommand{\titletext}{}
\makeindex
\makeindex[name=rhymes,title=Index of rhymes]

\begin{document}
\renewcommand{\titletext}{The Road Not Taken}
\poemtitle{\titletext} % \index[rhymes]{The Road Not Taken}
\begin{verse}
    Two roads diverged in a yellow wood,\\ \index[rhymes]{\titletext!ood}
    And sorry I could not travel both\\ \index[rhymes]{\titletext!oth}
    And be one traveler, long I stood\\ \index[rhymes]{\titletext!ood}
    And looked down one as far as I could\\ \index[rhymes]{\titletext!ood}
    To where it bent in the undergrowth;\\ \index[rhymes]{\titletext!oth}
\end{verse}

Another verse\index[rhymes]{Another verse}

Set more verse\index[rhymes]{Set more verse}

Even more verse\index[rhymes]{Even more verse}

%%%%%%%% use ood and oth as major index entries and tile as subentry

\poemtitle{\titletext} % \index[rhymes]{The Road Not Taken}
\begin{verse}
    Two roads diverged in a yellow wood,\\ \index[rhymes]{ood!\titletext}
    And sorry I could not travel both\\ \index[rhymes]{oth!\titletext}
    And be one traveler, long I stood\\ \index[rhymes]{ood!\titletext}
    And looked down one as far as I could\\ \index[rhymes]{ood!\titletext}
    To where it bent in the undergrowth;\\ \index[rhymes]{oth!\titletext}
\end{verse}

\printindex[rhymes]
\end{document}

在此处输入图片描述

有两种索引样式,一种是以poemtitle为主条目,另一种是以oodoth为主条目。也许其中一种更接近您想要的。

相关内容