1

I created custom lists with tocloft and succesfully typeset them as a replacement for a toc (It is about music sheets with songs being grouped in groups of songs). I now would like to have a list of songs at the beginning of each song set, like minitoc provides for toc. Is there a package to serve that purpose or do I have to write this from the ground up. As my TeX knowledge is very limited it would need a lot of larning about basic TeX.

A minimal example sketches my problem The class:

    \NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{songsheets}
[2015/10/01 v0.9h Class for song documentation]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptions
\LoadClass{book}

\RequirePackage{tocloft}


%table of songs stuff
\renewcommand{\cftdot}{$\cdot$}
\newlistof[songset]{song}{tos}{Songs}
\newlistentry{songset}{tos}{0}
\providecommand*{\toclevel@songset}{0}% 
\providecommand*{\toclevel@song}{1}% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   sectioning            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%

%definitions for a songset
\def\songsetname{Set}
\if@twoside
\def\ps@headings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
    \def\@evenhead{\thepage\hfil\slshape\leftmark}%
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\songsetmark##1{%
        \markboth {\MakeUppercase{%
                \ifnum \c@secnumdepth >\m@ne
                \if@mainmatter
                \songsetname \thesongset. \ %
                \fi
                \fi
                ##1}}{}}%
    \def\sectionmark##1{%
        \markright {\MakeUppercase{%
                \ifnum \c@secnumdepth >\z@
                \thesection. \ %
                \fi
                ##1}}}}
\else
\def\ps@headings{%
    \let\@oddfoot\@empty
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\songsetmark##1{%
        \markright {\MakeUppercase{%
                \ifnum \c@secnumdepth >\m@ne
                \if@mainmatter
                \songsetname \thesongset. \ %
                \fi
                \fi
                ##1}}}}
\fi
\def\ps@myheadings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
    \def\@evenhead{\thepage\hfil\slshape\leftmark}%
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\@gobbletwo
    \let\songsetmark\@gobble
    \let\sectionmark\@gobble
}
\newcommand*\songsetmark[1]{}
\renewcommand \thesongset {\@Roman\c@songset}
\newcommand\songset{\if@openright\cleardoublepage\else\clearpage\fi
    \thispagestyle{plain}%
    \global\@topnum\z@%
    \@afterindentfalse%
    \secdef\@songset%
    \@ssongset%
}
\def\@songset[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
    \refstepcounter{songset}%
    \typeout{Defsongset \thesongset.}%
    \addcontentsline{tos}{songset}%
    {\protect\numberline{\thesongset} #2}%
    \else
    \addcontentsline{tos}{songset}{#2}%
    \fi
    \songsetmark{#1}%
    \addtocontents{lof}{\protect\addvspace{10\p@}}%
    \addtocontents{lot}{\protect\addvspace{10\p@}}%
    \if@twocolumn
    \@topnewpage[\@makesongsethead{\songsetname}]%
    \else
    \@makesongsethead{#1}%
    \@afterheading
    \fi}
\def\@makesongsethead#1{%
\typeout{Makesongsethead #1} %
    %   \vspace*{50\p@}%
    {\parindent \z@ \raggedright \normalfont
        \interlinepenalty\@M
        \Huge \bfseries \songsetname\nobreakspace\thesongset\hfill#1\par\nobreak
        \vskip 40\p@
    }}
\def\@ssongset#1{\if@twocolumn
\typeout{Ssongset #1}%
    \@topnewpage[\@makessongsethead{#1}]%
    \else
    \@makessongsethead{#1}%
    \@afterheading
    \fi}
\def\@makessongsethead#1{%
    \vspace*{50\p@}%
    {\parindent \z@ \raggedright
        \normalfont
        \interlinepenalty\@M
        \Huge \bfseries \songsetname\nobreakspace\thesongset\hfill#1\par\nobreak
        \vskip 40\p@
    }}



%definitions for a song
\def\songname{Title}
\if@twoside
\def\ps@headings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
    \def\@evenhead{\thepage\hfil\slshape\leftmark}%
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\songmark##1{%
        \markboth {\MakeUppercase{%
                \ifnum \c@secnumdepth >\m@ne
                    \songname\space\thesong. \ %
                \fi
                ##1}}{}}%
    \def\sectionmark##1{%
        \markright {\MakeUppercase{%
                \ifnum \c@secnumdepth >\z@
                \thesection. \ %
                \fi
                ##1}}}}
\else
\def\ps@headings{%
    \let\@oddfoot\@empty
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\songmark##1{%
        \markright {\MakeUppercase{%
                \ifnum \c@secnumdepth >\m@ne
                \songname\space\thesong. \ %
                \fi
                ##1}}}}
\fi
\def\ps@myheadings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
    \def\@evenhead{\thepage\hfil\slshape\leftmark}%
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\@gobbletwo
    \let\songmark\@gobble
    \let\sectionmark\@gobble
}
\newcommand*\songmark[1]{}
\newcommand\song{\if@openright\cleardoublepage\else\clearpage\fi
    \thispagestyle{plain}%
    \global\@topnum\z@
    \@afterindentfalse
    \secdef\@song\@ssong}
\def\@song[#1]#2{\ifnum \c@secnumdepth >\m@ne
    \refstepcounter{song}%
    \typeout{\songname\space\thesong.}%
    \addcontentsline{tos}{song}%
    {\protect\numberline{\thesong} #2}%
    \else
    \addcontentsline{tos}{song}{#2}%
    \fi
    \songmark{#2}%
    \addtocontents{lof}{\protect\addvspace{10\p@}}%
    \addtocontents{lot}{\protect\addvspace{10\p@}}%
    \if@twocolumn
    \@topnewpage[\@makesonghead{#1}{#2}]%
    \else
    \@makesonghead{#1}{#2}%
    \@afterheading
    \fi}
\def\@makesonghead#1#2{%
%   \vspace*{50\p@}%
    {\parindent \z@ \raggedright \normalfont
        \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
        {\Large\bfseries \songname\space\thesong:}
%       \par\nobreak
%       \vskip 20\p@
        \fi
        \fi
        \interlinepenalty\@M
        {\Large \bfseries #2}\hfill
        }%

        \vskip 10\p@
    }
    \def\@ssong#1{\if@twocolumn
        \@topnewpage[\@makessonghead{#1}]%
        \else
        \@makessonghead{#1}%
        \@afterheading
        \fi}
    \def\@makessonghead#1{%
        \vspace*{50\p@}%
        {\parindent \z@ \raggedright
            \normalfont
            \interlinepenalty\@M
            \Huge \bfseries  #1\par\nobreak
            \vskip 40\p@
        }}

The document:

\documentclass{songlist} 

\begin{document}
\listofsong
\songset{}
I would like to have a table here, showing title1 and title2 as hyperlinks
\song[]{title1}content1
\song[]{title2}content2
\songset{}
I would like to have a table here, showing title3 and title4 as hyperlinks
\song[]{title3}content3
\song[]{title4}content4
\end{document}

To create tables of content at each chapter head, I should use minitoc. But I find no way to combine tocloft and minitoc in a way that the list of songs (named Songs) is given at each songset head just giving the songs in that songset. Does this make the question clear? If not, please don't hesitate to ask for details as I do not know which details you need.

  • The answer is a clear yes and no: You did not provide anything to start with – user31729 Oct 9 '15 at 16:16
  • Please post a complete Minimum Working Example (MWE). This is a complete but minimal document starting with \documentclass and ending with \end{document} which contains just enough for us to reproduce relevant features of your situation in order to help you. Not only does this make it easier to help (nobody likes setting puzzles up - only solving them). It automatically clarifies your question to at least a considerable extent. Right now, I'd have to do a lot to even try to figure out code which might be worth working on, and then I might not be able to help so... no incentive, really. – cfr Oct 19 '15 at 23:20
  • Instructions here – cfr Oct 19 '15 at 23:21
  • The working example is now there (original post). But it doesn't do waht I try to achieve. I just added text comments at the location where I want to achive something. – Ulrich Hauser-Ehninger Oct 21 '15 at 15:45
  • I reopened because a MWE has been added. – Stefan Kottwitz Nov 5 '15 at 10:08
0

Here is an approach. I added package etoc to the class file.

Class file songsheets.cls:

% modified by jfbu jeudi 05 novembre 2015 at 15:18:26
% (added etoc use)
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{songsheets}
[2015/10/01 v0.9h Class for song documentation]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptions
\LoadClass{book}

\RequirePackage{tocloft}
\RequirePackage{etoc}
\RequirePackage[linktoc=all]{hyperref}

% tocloft table of songs stuff
\renewcommand{\cftdot}{$\cdot$}

\newlistof[songset]{song}{tos}{Songs}
\newlistentry{songset}{tos}{0}
\providecommand*{\toclevel@songset}{0}
\providecommand*{\toclevel@song}{1}
% moved here
\newcommand*  \songsetmark [1]{}
\renewcommand*\thesongset  {\@Roman\c@songset}
\newcommand*  \songmark    [1]{}

% etoc table of songs stuff
\newcommand*{\tableofsongs}
{%
   \begingroup
      \@for\@tempa:=part,chapter,section,subsection,paragraph\do
           {\etocsetlevel{\@tempa}{6}}%
      \etocsetlevel{songset}{0}%
      \etocsetlevel{song}{1}%
      \etocsetnexttocdepth{song}%
      \renewcommand*\contentsname{Songs}%
      \tableofcontents
   \endgroup
}%
\newcommand*{\localtableofsongs}
{%
   \begingroup
      \@for\@tempa:=part,chapter,section,subsection,paragraph\do
           {\etocsetlevel{\@tempa}{6}}%
      \etocsetlevel{songset}{0}%
      \etocsetlevel{song}{1}%
      \etocsetnexttocdepth{song}%
      \etocsettocstyle{\addvspace{\baselineskip}}{}%
      \localtableofcontents
   \endgroup
}%


%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   sectioning            %
%%%%%%%%%%%%%%%%%%%%%%%%%%%

%definitions for a songset
\def\songsetname{Set}
\if@twoside
\def\ps@headings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
    \def\@evenhead{\thepage\hfil\slshape\leftmark}%
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\songsetmark##1{%
        \markboth {\MakeUppercase{%
                \ifnum \c@secnumdepth >\m@ne
                \if@mainmatter
                \songsetname \thesongset. \ %
                \fi
                \fi
                ##1}}{}}%
    \def\sectionmark##1{%
        \markright {\MakeUppercase{%
                \ifnum \c@secnumdepth >\z@
                \thesection. \ %
                \fi
                ##1}}}}
\else
\def\ps@headings{%
    \let\@oddfoot\@empty
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\songsetmark##1{%
        \markright {\MakeUppercase{%
                \ifnum \c@secnumdepth >\m@ne
                \if@mainmatter
                \songsetname \thesongset. \ %
                \fi
                \fi
                ##1}}}}
\fi
\def\ps@myheadings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
    \def\@evenhead{\thepage\hfil\slshape\leftmark}%
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\@gobbletwo
    \let\songsetmark\@gobble
    \let\sectionmark\@gobble
}
% moved to top of file
% \newcommand*\songsetmark[1]{}
% \renewcommand \thesongset {\@Roman\c@songset}
\newcommand\songset{\if@openright\cleardoublepage\else\clearpage\fi
    \thispagestyle{plain}%
    \global\@topnum\z@%
    \@afterindentfalse%
    \secdef\@songset%
    \@ssongset%
}
\def\@songset[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
    \refstepcounter{songset}%
    \typeout{Defsongset \thesongset.}%
      % \addcontentsline{tos}{songset}{\protect\numberline{\thesongset} #2}%
      % replaced by etoc use of toc file
      \addcontentsline{toc}{songset}{\protect\numberline{\thesongset} #2}%
    \else
      % \addcontentsline{tos}{songset}{#2}%
      % replaced by etoc use of toc file
      \addcontentsline{toc}{songset}{#2}%
    \fi
    \songsetmark{#1}%
    \addtocontents{lof}{\protect\addvspace{10\p@}}%
    \addtocontents{lot}{\protect\addvspace{10\p@}}%
    \if@twocolumn
    \@topnewpage[\@makesongsethead{\songsetname}]%
    \else
    \@makesongsethead{#1}%
    \@afterheading
    \fi}
\def\@makesongsethead#1{%
\typeout{Makesongsethead #1} %
    %   \vspace*{50\p@}%
    {\parindent \z@ \raggedright \normalfont
        \interlinepenalty\@M
        \Huge \bfseries \songsetname\nobreakspace\thesongset\hfill#1\par\nobreak
        \vskip 40\p@
    }}
\def\@ssongset#1{\if@twocolumn
\typeout{Ssongset #1}%
    \@topnewpage[\@makessongsethead{#1}]%
    \else
    \@makessongsethead{#1}%
    \@afterheading
    \fi}
\def\@makessongsethead#1{%
    \vspace*{50\p@}%
    {\parindent \z@ \raggedright
        \normalfont
        \interlinepenalty\@M
        \Huge \bfseries \songsetname\nobreakspace\thesongset\hfill#1\par\nobreak
        \vskip 40\p@
    }}



%definitions for a song
\def\songname{Title}
\if@twoside
\def\ps@headings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
    \def\@evenhead{\thepage\hfil\slshape\leftmark}%
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\songmark##1{%
        \markboth {\MakeUppercase{%
                \ifnum \c@secnumdepth >\m@ne
                    \songname\space\thesong. \ %
                \fi
                ##1}}{}}%
    \def\sectionmark##1{%
        \markright {\MakeUppercase{%
                \ifnum \c@secnumdepth >\z@
                \thesection. \ %
                \fi
                ##1}}}}
\else
\def\ps@headings{%
    \let\@oddfoot\@empty
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\songmark##1{%
        \markright {\MakeUppercase{%
                \ifnum \c@secnumdepth >\m@ne
                \songname\space\thesong. \ %
                \fi
                ##1}}}}
\fi
\def\ps@myheadings{%
    \let\@oddfoot\@empty\let\@evenfoot\@empty
    \def\@evenhead{\thepage\hfil\slshape\leftmark}%
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\@gobbletwo
    \let\songmark\@gobble
    \let\sectionmark\@gobble
}
% \newcommand*\songmark[1]{}
\newcommand\song{\if@openright\cleardoublepage\else\clearpage\fi
    \thispagestyle{plain}%
    \global\@topnum\z@
    \@afterindentfalse
    \secdef\@song\@ssong}
\def\@song[#1]#2{\ifnum \c@secnumdepth >\m@ne
    \refstepcounter{song}%
    \typeout{\songname\space\thesong.}%
    %  \addcontentsline{tos}{song}{\protect\numberline{\thesong} #2}%
    % use of toc file for etoc
      \addcontentsline{toc}{song}{\protect\numberline{\thesong} #2}%
    \else
    %  \addcontentsline{tos}{song}{#2}%
    % use of toc file for etoc
      \addcontentsline{toc}{song}{#2}%
    \fi
    \songmark{#2}%
    \addtocontents{lof}{\protect\addvspace{10\p@}}%
    \addtocontents{lot}{\protect\addvspace{10\p@}}%
    \if@twocolumn
    \@topnewpage[\@makesonghead{#1}{#2}]%
    \else
    \@makesonghead{#1}{#2}%
    \@afterheading
    \fi}
\def\@makesonghead#1#2{%
%   \vspace*{50\p@}%
    {\parindent \z@ \raggedright \normalfont
        \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
        {\Large\bfseries \songname\space\thesong:}
%       \par\nobreak
%       \vskip 20\p@
        \fi
        \fi
        \interlinepenalty\@M
        {\Large \bfseries #2}\hfill
        }%

        \vskip 10\p@
    }
    \def\@ssong#1{\if@twocolumn
        \@topnewpage[\@makessonghead{#1}]%
        \else
        \@makessonghead{#1}%
        \@afterheading
        \fi}
    \def\@makessonghead#1{%
        \vspace*{50\p@}%
        {\parindent \z@ \raggedright
            \normalfont
            \interlinepenalty\@M
            \Huge \bfseries  #1\par\nobreak
            \vskip 40\p@
        }}

Document songlist.tex:

\documentclass{songsheets} 
\begin{document}
\tableofsongs
\songset{}
I now have a table here, showing title1 and title2 as hyperlinks.
\localtableofsongs
\song[]{title1}content1
\song[]{title2}content2
\songset{}
I now have a table here, showing title3 and title4 as hyperlinks.
\localtableofsongs
\song[]{title3}content3
\song[]{title4}content4
\end{document}

Output:

Page 1:

Blockquote

Page 3:

Blockquote

Page 9:

Blockquote

Again page 1, to show the hyperlinks as red boxes:

enter image description here

|improve this answer|||||
  • Thank you very much. I had found etoc in the meantime as well. I have toyed with it a little and am close to a solution. As I have not completely succeeded yet I haven't commented here, but I am pretty sure that etoc is a perfectly working solution here. – Ulrich Hauser-Ehninger Nov 6 '15 at 11:56
  • Yes, thank you, this is a solution. I didn't expect etoc and tocloft to work nicely together. – Ulrich Hauser-Ehninger Nov 18 '15 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.