LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and AcronymsMake index list section, index item?

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
bombcar
Posts: 22
Joined: Tue Oct 28, 2008 10:18 pm

Make index list section, index item?

Postby bombcar » Sun Dec 27, 2009 7:55 am

I am overriding the index functionality it possibly horrible ways to make a list of songs in my document.

  1. \documentclass[b5paper]{book}
  2. \usepackage{multicol}
  3.  
  4. \makeatletter
  5. \newcommand{\makesongs}{%
  6. \makeindex
  7. \bgroup
  8. \def\indexsection\numberline##1##2\endindexsection{%
  9. \protected@write\@indexfile{}{\string\indexentry{##2}{##1}}}%
  10. \def\contentsline##1##2##3{\indexsection##2\endindexsection}%
  11. \@input@{\jobname.toc}%
  12. \egroup
  13. }
  14.  
  15. \newcommand{\listofsongs}{%
  16. \begingroup
  17. \@input@{\jobname.ind}%
  18. \if@filesw
  19. \expandafter\newwrite\csname tf@toc\endcsname
  20. \immediate\openout\csname tf@toc\endcsname\jobname.toc\relax
  21. \fi
  22. \@nobreakfalse
  23. \endgroup}
  24.  
  25. \newcommand*{\songsection}[2][]{%
  26. \newpage
  27. \def\thesongtitle{#1}%
  28. \ifx\thesongtitle\@empty
  29. \section{#2}%
  30. \else
  31. \section[#1@#2]{#2}%
  32. \fi
  33. }
  34. \makeatother
  35.  
  36. \makesongs
  37. \begin{document}
  38. % Document is here
  39.  
  40. \newpage
  41.  
  42. \begin{multicols}{2}
  43. \listofsongs
  44. \end{multicols}
  45. \end{document}


This is working pretty well, but I'm getting things like:

  1. song . . . . . . . . 22


Which is fine, but I'd rather have:



instead.

My songs.ist is:

  1. preamble "\\section*{List of Songs}"
  2. postamble ""
  3. group_skip ""
  4. item_0 "\n\\contentsline\{section\}\{"
  5. delim_0 "\}\{"
  6. delim_t "\}"
  7. headings_flag 0
  8. level '>'


Everything I try to do to make it operate differently seems to break on \numberline or \contentsline. Any ideas?

Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”

Who is online

Users browsing this forum: No registered users and 1 guest