Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
Have you tried the tocloft package? –  uli Nov 22 '11 at 17:51
3  
Please don't ask "How do I achieve this layout", but rather a question about a specific feature that you're struggling with, one problem per question. This way other users who have a similar problem can benefit from your question and the solutions to it (No one's gonna ask for the same layout as you). It's no problem to ask several questions, if you've made some attempt yourself first. It's enormously helpful to see what you've tried so far to figure out what doesn't work. If you don't know where to start at all, I suggest changing your question to "Packages to customize the table of contents" –  doncherry Nov 22 '11 at 17:53
    
You have now 6 questions with answers, but without an accepted one. If an answer solves your question, please think about accepting it by clicking at the check mark at the left of the answer (which gives reputation to the answerer and to yourself). I think Schweinebacke's (edited) answer solves the question, doesn't it? Additionally you can upvote helpful answers by clicking at the upward-symbol at the left of the answer (the number of upvoted answers is not limited - ok, 40 per day, i.e. if three answers to one question were helpful, you can upvote all three of them). –  Stephen Nov 22 '11 at 19:25
2  
@Stephen: Thanks for your explanation. Just did some "accepts" and upvotes. –  Moked Nov 22 '11 at 21:51
add comment

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
    
Added \addtocontents{toc}{\smallskip \textbf{Zu diesem Heft} \par \smallskip } after ToC and \addtocontents{toc}{\bigskip \textbf{Beiträge} \par \smallskip } after the Vorwort via edit (hope that's ok). –  Stephen Nov 22 '11 at 18:57
    
In my document all the individual articles are chapters (so I modified \authorsection accordingly) but further subdivison in sections and subsections is allowed. Those should be excluded from the table of contents anyway, so I set \setcounter{tocdepth}{\chapterlevel} (otherwise they would even appear in the toc before the chapter they are included in). But then the line with the title name, dots and page numbers disappears from the toc. What am I doing wrong? –  Moked Nov 22 '11 at 21:30
1  
@Stephen: Please don't use \pagebreak where \newpage or \cleardoublepage should be used. \pagebreak may result in strange vertical alignment of the paragraphs of the page. I'll change this. –  Schweinebacke Nov 23 '11 at 6:43
    
@Sebastian Krause: Where does the \chapterlevel come from? Which class do you use? Maybe you could add this information simply to your question? –  Schweinebacke Nov 23 '11 at 6:45
    
@Sebastian Krause: Maybe you've done not enough LaTeX runs after the changes. I've changed my answer to use scrbook instead of article, and cleaned up markup of additional material added by Stephen. –  Schweinebacke Nov 23 '11 at 7:45
show 1 more comment

If you are interested in changing the ToC, you might be interested in the titletoc package. You can add arbitrary content (like "Beiträge") to the ToC by \addtocontents{toc}{ <something> }, e.g.

\addtocontents{toc}{\bigskip \textbf{Beiträge} \par \smallskip }

. Whole entries can be added with

\addcontentsline{toc}{chapter}{Beitr{\"{a}}ge}

(where chapter is the according level, others would be e.g. part or section).

\dotfill \pageref{ first page of chapter label } -- \pageref{ last page of chapter label }

(where there is a label placed at the first and another one at the end of each chapter) would create the "...... 7-12" part of the entries in case you create everything by \addcontentsline, but probably you want a package automatically doing it (sorry, I do not know of any one doing this).

share|improve this answer
1  
But what about the page numbering (first page-last page)? –  Werner Nov 22 '11 at 17:57
2  
How about assembling your discussion into a compilable MWE so as to specify the procedure and usage almost verbatim? You never know how many users may benefit from an MWE. –  Werner Nov 22 '11 at 18:17
    
@Werner: Well, Schweinebacke just submitted a MWE which produces a ToC as asked for (I gave +1 for that). Thus there is the MWE, and here is a little explanation about \addtocontents / \addcontentsline. (When Schweinebacke had submitted his MWE first, I would have submitted my answer as comment.) –  Stephen Nov 22 '11 at 18:41
    
@Werner: Added \addtocontents{toc}{\bigskip \textbf{Beiträge} \par \smallskip } and \addtocontents{toc}{\bigskip \textbf{Beiträge} \par \smallskip } after the Vorwort (and the Hans Seidel-Beitrag which is a one-liner) to Schweinebacke's answer, which is now exactly what the OP asked for. –  Stephen Nov 22 '11 at 19:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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