# Additional values besides title in TOC

I have an article class with multiple sections. I would like to include more values in TOC, beside just the title of the section, in a table representation. For better understanding: it will be a song book, where the section does not have a "title", but "song title" and "interpret". The following ssce shows what I mean:

\documentclass{article}

\begin{document}
\tableofcontents
\section[FIRST VALUE - SECOND VALUE]{FIRST VALUE}{test1}
\section[FIRST - VALUE - WITH - HYPEN - STILL SECOND VALUE]{FIRST - VALUE - WITH - HYPEN}{test2}
\section[FIRST - VALUE - WITH - HYPEN - ALSO SECOND VALUE - WITH HYPEN]{FIRST - VALUE - WITH - HYPEN}{test3}

\section*{Expected TOC}{
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{\textbf{\#}} & \multicolumn{1}{c|}{\textbf{Title}} & \multicolumn{1}{c|}{\textbf{Interpret}} \\ \hline
1                                 & FIRST VALUE                         & SECOND VALUE                            \\ \hline
2                                 & FIRST - VALUE - WITH - HYPEN        & STILL SECOND VALUE                      \\ \hline
3                                 & FIRST - VALUE - WITH - HYPEN        & ALSO SECOND VALUE - WITH HYPEN          \\ \hline
\end{tabular}
}
\end{document}


generates:

Based on the sections I try to create the result from "Expected TOC". But unfortunatly I am not able to find any help online. I assume I am using wrong buzzwords for it. Can anyone point in the right direction to look at? Since I am using leadsheet package for the chord notation I am limited to "section" usage.

Here is an example of more real scenario:

\documentclass{article}
\usepackage{array}

\definesongtitletemplate{title}{
\ifsongmeasuring {
\section*
}{
\section[\songproperty{title}\hfill\songproperty{interpret}]{\songproperty{title}}
}
}

\begin{document}
\tableofcontents
\begin{song}{title={Song 1}, interpret={Author 1}}
\begin{verse}
Mary had a little lamb \\
Its fleece was white as snow, yea \\
\end{verse}
\end{song}
\begin{song}{title={Song 2}, interpret={Auth fdsa fdsa fdsa fdsafsor 2}}
\begin{verse}
Mary had a little lamb \\
Its fleece was white as snow, yea \\
\end{verse}
\end{song}
\begin{song}{title={Song fdsa fdsa fdsa fdsa fdas 3}, interpret={Author 3}}
\begin{verse}
Mary had a little lamb \\
Its fleece was white as snow, yea \\
\end{verse}
\end{song}
\end{document}


The section title contains \hfill between the values, but it makes the song title left aligned and the interpret right aligned.

• Welcome to TeX.se. Do you really need the lines? Getting the data into a TOC isn't that hard, but contents lists aren't set as tabular material and so things that you can do with regular tables aren't so trivial. – Alan Munn Oct 21 at 17:59
• I do not need the lines, but I need the list of interprets be on the same level. On the other hand, I only assume, that its a topic for TOC, maybe there is another way without tableofcontents usage – Alex Volodko Oct 21 at 18:01
• The leadsheets information seems quite relevant. It's a complex package (or class) that can do a lot of things, so you may want to edit your question to show a minimal example using it rather than the one you've shown us here. – Alan Munn Oct 21 at 18:06
• Looking quickly at the documentation it seems that you should define a new songtitle template modeled on the tabular template, and then simply add the relevant information you want to the \section code. E.g. \section[\songproperty{title}\hfill\songproperty{music}]{\songproperty{title}} – Alan Munn Oct 21 at 18:36
• I added a more realistic example with your suggestion about hfill. It makes the interpreter righ aligned. I assume this is exactly what you ment by "not tabular material" regarding table of content? – Alex Volodko Oct 21 at 18:54

I was able to achive the goal using etoc and substr packages. With etoc package it is possible to create tables as TOC and with substr package I am extracting the parts of the section title:

\documentclass{article}
\usepackage{array}
\usepackage{etoc}
\usepackage{longtable}
\usepackage{bookmark}
\usepackage{substr}
\usepackage{framed}
\usepackage{varioref}

\definesongtitletemplate{title}{
\ifsongmeasuring {
\section*
}{
\section[\songproperty{title}!-!?!\songproperty{interpret}]{\songproperty{title}}
}
}

\etocglobaldefs

\etocsetstyle{section}
{}
{\etociffirst{\etocifnumbered{\\\hline}{\\\hline\hline}}{\\\hline}}
{\etocnumber & \BeforeSubString{!-!?!}{\etocthename} & \BehindSubString{!-!?!}{\etocthename}}
{}

\etocsettocstyle{
\begin{longtable}{
|>{\bfseries}c|p{7cm}|p{7cm}|
}
\multicolumn{3}{c}{\Large\bfseries\strut\strut Songlist}
\\\hline
\ & \textbf{Title} & \textbf{Interpret}
}
{
\\\hline
\end{longtable}
}

\begin{document}
\tableofcontents
\begin{song}{title={Song 1}, interpret={Author 1}}
\begin{verse}
Mary had a little lamb \\
Its fleece was white as snow, yea \\
\end{verse}
\end{song}
\begin{song}{title={Song 2}, interpret={Auth fdsa fdsa fdsa fdsafsor 2}}
\begin{verse}
Mary had a little lamb \\
Its fleece was white as snow, yea \\
\end{verse}
\end{song}
\begin{song}{title={Song fdsa fdsa fdsa fdsa fdas 3}, interpret={Author 3}}
\begin{verse}
Mary had a little lamb \\
Its fleece was white as snow, yea \\
\end{verse}
\end{song}
\end{document}


This ends up as expected: I am not sure if this string handling really is the "latex way" to go, but it works.