0

I try to make an “index of rhymes” in a poem collection.

So, I began to set an index called “Index of rhymes”:

\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}

And the output is this one Output

So, the the page is correctly set for each rhyme. But instead of page, I try to make it show the poem title set with \poemtitle.

So, is it possible to catch the last \poemtitle’s value and use it in the index near each rhyme instead of the page number where it’s used?

The expected rendering is something like that:

enter image description here

1 Answer 1

1

I don't know how to replace a page number in an index with something else. But have a look at this:

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

enter image description here

There are two index styles, one with the poemtitle as the main entry and the other with your ood and oth as main entries. Perhaps one of these is closer to what you are after.

1
  • Great. I was looking for the rhymes ood and othas main entries. Now, I just need to hide page number.
    – fauve
    Commented Apr 24, 2022 at 18:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .