[Tex/LaTex] Customized table of contents

formattingpackagestable of contents

I need to format the table of contents for a compilation of articles in a very specific format:

About this volume
Author 1
    Preface........................first page-last page

Articles

Author 2
    Title 2........................first page-last page
Author 3
    Title 3........................first page-last page
Author 4
    Title 4........................first page-last page

Except for a small difference concerning the page number it should look like this (German) example:

Does anyone have ideas how to do it, what packages to use or maybe some coded example?

Best Answer

Here is a small example with authors at the table of contents and with first till last page.

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage[ngerman]{babel}

\makeatletter
\providecommand*{\addchap}[1]{% define if, if you are not using a KOMA-Script class
  \chapter*{#1}\markboth{#1}{}%
}

% document commands

\newenvironment{authorsection}[2][]{% optional arg = author; mandatory arg = title
  \cleardoublepage
  \addtocontents{toc}{\protect\startauthorsection{#1}{#2}{\thepage}}%
  \addchap{#2}% Don't use a number
}{%
  \addtocontents{toc}{\protect\finishauthorsection{\thepage}}%
}

\newcommand*{\addtocpart}[1]{% add something like a part but only start a new
                             % (odd) page and set up a toc-entry without page
                             % number
  \cleardoublepage
  \addtocontents{toc}{\protect\tocpart{#1}}%
}

\setcounter{tocdepth}{0}% only chapters at the table of contents
\setcounter{secnumdepth}{-1}% No chapter, section etc. numbers

% toc commands

\newcommand*{\aname}{}% needed to store author until end
\newcommand*{\stitle}{}% needed to store title until end
\newcommand*{\fpage}{}% needed to store page until end
\newcommand{\startauthorsection}[3]{% #1 = author, #2 = title, #3 = page
  \def\aname{#1}%
  \def\stitle{#2}%
  \def\fpage{#3}%
  \begingroup
    \let\l@chapter\@gobbletwo% deactivate chapter entries
}
\renewcommand*{\l@chapter}{%
  \addvspace{\baselineskip}%
  \@dottedtocline{0}{0pt}{1.5em}% use chapter entries with dots
}%
\newcommand*{\finishauthorsection}[1]{% #1 = page
  \endgroup% reactivate normal chapter entries
  \l@chapter{% make a chapter entry
    \normalfont% but with normal font
    \ifx\aname\@empty\unskip\else\mbox{\itshape\aname}\\\fi% show the author if there's any
    \stitle% show the title
  }{\fpage--#1}% and the page range
}

\newcommand*{\tocpart}[1]{%
  \addvspace{2\baselineskip}
  \setlength{\parindent}{0pt}
  \textbf{#1}\par
  \smallskip
}

% neeed more space for page numbers at toc:
\renewcommand*{\@pnumwidth}{3em}
\renewcommand*{\@tocrmarg}{4em}

\makeatother

\begin{document}
\tableofcontents

\addtocpart{Zu diesem Heft}

\begin{authorsection}[Rüdiger Lux]{Vorwort}
\lipsum
\end{authorsection}

\addtocpart{Beiträge}

\begin{authorsection}[Hans Seidel]{20 Jahre Forschungsstelle Judentum 1988--2008}
  \lipsum
\end{authorsection}

\begin{authorsection}[Harald Samuel]{Leipzig -- Jerusalem -- Rom\protect\\
Mit Hebräisch spielend unterwegs}
  \lipsum
  \section{Überschrift innerhalb der Geschichte}
  \lipsum
\end{authorsection}

\end{document}

I've used a KOMA-Script class, because AFAIK most Germans like to use them. But you may replace it by a standard class. While you've commented, that you are using \chapter, I'm using a book class. You may change this into a report class. But if you change it into a article class, you have to replace e.g. \addchap by \addsec, \chapter* by \section*, \section by \subsection, \l@chapter by \l@section.