GeneralCreate alphabetical list of sections?

LaTeX specific issues not fitting into one of the other forums of this category.
theophile
Posts: 1
Joined: Wed Sep 01, 2010 6:34 am

Create alphabetical list of sections?

Post by theophile »

Sorry if resurrecting old threads is frowned on, but I have a very similar question.

Like bombcar, I am creating a hymnal using LaTeX and lilypond-book, and I have a working template with autogenerated index of songs using the code above in this thread. But now I'm getting greedy, and I'd like to see if I can use the multind package to create multiple indices for song title, tune title, composer name, text author name, even song meter.

I tried minimally altering the above examples by changing:

Code: Select all

\makeatletter
\newcommand{\makesongs}{%
  \makeindex
  \bgroup
     \def\indexsection\numberline##1##2\endindexsection{%
       \protected@write\@indexfile{}{\string\indexentry{##2}{##1}}}%
     \def\contentsline##1##2##3{\indexsection##2\endindexsection}%
     \@input@{\jobname.toc}%
  \egroup
}
to

Code: Select all

\makeatletter
\newcommand{\makesongs}{%
  \makeindex{titles}
  \bgroup
     \def\indexsection\numberline##1##2\endindexsection{%
       \protected@write\@indexfile{}{\string\indexentry{##2}{##1}}}%
     \def\contentsline##1##2##3{\indexsection##2\endindexsection}%
     \@input@{\jobname.toc}%
  \egroup
}
But pdflatex dies with an error. I'm sure there's more to it than that, but honestly, my LaTeX-fu is very weak. Any suggestions would be much appreciated! TIA!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Create alphabetical list of sections?

Post by nlct »

multind uses \<label>@idxfile instead of \@indexfile to point to the index file. Since you've called your index file "titles", you'll need to replace \@indexfile with \titles@idxfile.

Code: Select all

\newcommand{\makesongs}{%
  \makeindex{titles}
  \bgroup
     \def\indexsection\numberline##1##2\endindexsection{%
       \protected@write\titles@idxfile{}{\string\indexentry{##2}{##1}}%
     }%
     \def\contentsline##1##2##3{\indexsection##2\endindexsection}%
     \@input@{\jobname.toc}%
  \egroup
}
Regards
Nicola Talbot
Post Reply