我尝试在诗集中制作“押韵索引”。
于是,我开始定一个索引,叫“押韵索引”:
\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
为主条目,另一种是以ood
和oth
为主条目。也许其中一种更接近您想要的。