4

I'm building a song book with the songs package from songs.sourceforge.net and I'm trying to create topical indexes for songs. The small indexes consume an entire page each. I'd like to squeeze them so they don't take up a whole page.

Here's an MWE:

\documentclass[12pt,twoside,titlepage]{article}
\usepackage[top=0.7in, bottom=0.7in, left=1in, right=1in]{geometry}
\usepackage{times}
\title{My MWE}

\usepackage[lyric]{songs}
\newindex{titleidx}{titleidx}
\newauthorindex{authoridx}{authoridx}
\newindex{mytopic}{mytopicidx}
\begin{document}

\songcolumns{1}

\showindex{Title Index}{titleidx}
\showindex{Author Index}{authoridx}
\showindex{My Topic}{mytopic}


\songsection{}

\begin{songs}{titleidx,authoridx}


\beginsong{Just some song}[
  by={me},
  cr={},
  li={}]

\indextitleentry[mytopic]{\songtitle}

\endsong

\end{songs}

\end{document}
0

2 Answers 2

2

A redefinition of the internal macro \SB@displayindex is necessary:

\documentclass[12pt,twoside,titlepage]{article}
\usepackage[top=0.7in, bottom=0.7in, left=1in, right=1in]{geometry}
\usepackage{times}
\title{My MWE}

\usepackage[lyric]{songs}
\newindex{titleidx}{titleidx}
\newauthorindex{authoridx}{authoridx}
\newindex{mytopic}{mytopicidx}


\makeatletter
\renewcommand\SB@displayindex[3]{%
  \ifsongindexes\begingroup%
    \SB@colwidth\hsize%
    \advance\SB@colwidth-#1\columnsep%
    \advance\SB@colwidth\columnsep%
    \divide\SB@colwidth#1%
    \setbox\SB@idxtitlebox\vbox{%
      \let\SB@temp\songsection%
      \ifx\chapter\undefined\else%
        \ifx\chapter\relax\else%
          \let\SB@temp\songchapter%
        \fi%
      \fi%
      \SB@temp{#2}%
    }%
    \IfFileExists{\csname SB@idxfilename@#3\endcsname.sbx}{%
      \ifx\hyperlink\undefined\let\hyperlink\@secondoftwo\fi%
      \ifx\hyperlink\relax\let\hyperlink\@secondoftwo\fi%
      \global\setbox\SB@box\vbox{%
        \null%
        \vfil%
        \unvcopy\SB@idxtitlebox%
        \vskip.5in\@minus.3in\relax%
        \hbox to\hsize{%
          \hfil%
          \vbox{%
            \hsize\SB@colwidth%
            \renewenvironment{idxblock}[1]%
              {\begin{SB@smidx}{####1}}{\end{SB@smidx}}%
            \let\\\SB@idxitemsep%
            \input{\csname SB@idxfilename@#3\endcsname.sbx}%
          }%
          \hfil%
        }%
        \vskip\z@\@plus2fil\relax%
      }%
      {\vbadness\@M\vfuzz\maxdimen%
       \splitmaxdepth\maxdepth\splittopskip\z@skip%
       \global\setbox\SB@boxii\vsplit\SB@box to\textheight}%
      \ifvoid\SB@box%
        \box\SB@boxii%
      \else%
        \global\setbox\SB@box\vbox{%
          \renewenvironment{idxblock}[1]%
            {\begin{SB@lgidx}{####1}}{\end{SB@lgidx}}%
          \let\\\SB@idxitemsep%
          \SB@idxsetup{#1}%
          \input{\csname SB@idxfilename@#3\endcsname.sbx}%
          \unskip%
        }%
        \SB@toks{\SB@makeidxcolumn{#1}}%
        \SB@cnt#1\relax%
        \loop\ifnum\SB@cnt>\@ne%
          \SB@toks\expandafter{\the\SB@toks%
            \kern\columnsep\SB@makeidxcolumn{#1}}%
          \advance\SB@cnt\m@ne%
        \repeat%
        \edef\SB@oneidxpage{\the\SB@toks}%
        \unvbox\SB@idxtitlebox%
        \vskip.2in\relax%
        \nointerlineskip%
        \null%
        \nointerlineskip%
        \SB@cnt\vbadness\vbadness\@M%
        \SB@dimenii\vfuzz\vfuzz\maxdimen%
        \loop%
          \SB@dimen\textheight%
          \ifinner\else\kern\z@\advance\SB@dimen-\pagetotal\fi%
          \global\setbox\SB@boxii\copy\SB@box%
          \global\setbox\SB@boxiii\hbox{\SB@oneidxpage}%
          \ifdim\ht\SB@box>\z@%
            \box\SB@boxiii%
            \vfil\break%
        \repeat%
        \SB@dimenii\ht\SB@boxii%
        \divide\SB@dimenii#1\relax%
        \SB@maxmin\SB@dimen>\SB@dimenii%
        \loop%
          \global\setbox\SB@box\copy\SB@boxii%
          \global\setbox\SB@boxiii\hbox{\SB@oneidxpage}%
          \ifdim\ht\SB@box>\z@%
            \advance\SB@dimen\p@%
        \repeat%
        \box\SB@boxiii%
        \global\setbox\SB@boxii\box\voidb@x%
        \vbadness\SB@cnt\vfuzz\SB@dimenii%
      \fi%
    }%
    {%
      \vbox{%Changed
        \vfil%
        \unvbox\SB@idxtitlebox%
        \vskip1em\relax%
        \hbox to\hsize{\hfil[Index not yet generated.]\hfil}%
        \vskip2em\@plus2fil\relax%Changed
      }%
    }%
    %\clearpage%Changed
  \endgroup\fi%
}
\makeatother
\begin{document}

\songcolumns{1}

\showindex{Title Index}{titleidx}
\showindex{Author Index}{authoridx}
\showindex{My Topic}{mytopic}
\clearpage

\songsection{}

\begin{songs}{titleidx,authoridx}


\beginsong{Just some song}[
  by={me},
  cr={},
  li={}]

\indextitleentry[mytopic]{\songtitle}

\endsong

\end{songs}

\end{document}

enter image description here

0

Version 2.13 and later of the songs package contains a special macro for this purpose. Just put \sepindexesfalse in your document prelude.

You must log in to answer this question.

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