2

I created a songbook using the songbook package. As stated in the manual I added a \makeTitleIndex command to the preamble of my songbook. It creates a .tIdx file containing song titles and song numbers. However, I need the page numbers instead.

Is there a way to configure \makeTitleIndex to output page numbers (even though it is a parameterless command)? If not, what alternatives do I have? I'd like to use makeindex to convert the .tIdx to a .tdx.

Here an example: songbook.tex:

\documentclass[a4paper,10pt]{book}
\usepackage[ngerman]{babel}
\usepackage[chordbk]{songbook}

\begin{document}

    \makeTitleIndex

    \begin{song}{Song 1}{}{~}{}{}{} 
        song1
        \newpage
        song1 continued
    \end{song}


    \begin{song}{Song 2}{}{~}{}{}{}
        song2
    \end{song}

    \begin{song}{Song 3}{}{~}{}{}{}
        song3
    \end{song}

    \input{songbook.tdx}

\end{document}

Compile once. Then run:

makeindex -o songbook.tdx songbook.tIdx

Compile again. Note the index at end of PDF shows song numbers (not page numbers).

1 Answers1

2

The song environment uses \titleIndex{\theSongTitle}{\theSBSongCnt} to make the index entry with song title and song counter value.

This can be patched with \xpatchcmd to change \theSBSongCnt to \thepage.

\documentclass[a4paper,10pt]{book}
\usepackage[ngerman]{babel}
\usepackage[chordbk]{songbook}
\usepackage{xpatch}

\xpatchcmd{\song}{%
  \titleIndex{\theSongTitle}{\theSBSongCnt}   %
}{%
  \titleIndex{\theSongTitle}{\thepage}   %
}{}{}


\begin{document}

    \makeTitleIndex

    \begin{song}{Song Foo}{}{~}{}{}{} 
        song1
        \newpage
        song1 continued
    \end{song}


    \begin{song}{Song Foobar}{}{~}{}{}{}
        song2
    \end{song}

    \begin{song}{Song Other Foobar}{}{~}{}{}{}
        song3
    \end{song}

    \input{songbook.tdx}

\end{document}

enter image description here