I'm trying to understand, in some detail, how a toc is generated. But now I'm thoroughly confused and perplexed after examining the .toc file before and after making a ``slight'' modification. I hope someone can get me past this bottleneck. [The final goal is to design a ToC where where I can place the chapter title (not chaptername or chapternum), author, and page number all on one line, sometimes two. For a particular book or report, the title, author, or page should appear in the user preferred order. The title should appear in one header, the author in the other: a later question, I suspect]
I started with a simple file, nothing fancy, just 2 chapters.
\documentclass{book}
\usepackage{lipsum}
%\newcommand\autsection[2]{%
% \chapter[#1~/ {\normalfont\small\itshape#2}] %
% {#1 \\ {\normalfont\large\itshape#2}}} %
\begin{document}
\tableofcontents
\chapter{Title without slash Author}
%\autsection{Title with slash Author}{Paul Isamber}
\lipsum[20-30]
\chapter{Very long title name without slash author or any other text in the title}
%\autsection{Very long title name with slash author following}{Joseph Wright and Timothy Hall}
\end{document}
They generated this .toc file. Straight forward it seems.
\contentsline {chapter}{\numberline {1}Title without slash Author}{3}
\contentsline {chapter}{\numberline {2}Very long title name without slash author or any other text in the title}{7}
Then I added a small modification, based on an answer by G.Medina (Add author's name automatically while building ToC on Mar 10, 2012 by Gonzalo Medina)
\newcommand\autsection[2]{% alternative
\section[#1~/ {\normalfont\small\itshape#2}] % optional part of \section
{#1 \\ {\normalfont\large\itshape#2}}} % main part of \section
And I substituted these two macros for the \chapter commands.
\autsection{Title with slash Author}{Paul Isamber}
\autsection{Very long title name with slash author following}{Joseph Wright and Timothy Hall}
The contents of the .toc file is what confused me. Note that I've reformatted the file to make it easier to read, and only include the code that refers to the first chapter
\contentsline {chapter}{\numberline {1}Title with slash Author
\nobreakspace {}/
{\normalfont \relax
\fontsize {9}{11}\selectfont
\abovedisplayskip 8.5\p@ plus3\p@ minus4\p@
\abovedisplayshortskip \z@ plus2\p@
\belowdisplayshortskip 4\p@ plus2\p@ minus2\p@
\def \leftmargin \leftmargini
\parsep 4\p@ plus2\p@ minus\p@
\topsep 8\p@ plus2\p@ minus4\p@
\itemsep 4\p@ plus2\p@ minus\p@ {%
\leftmargin \leftmargini
\topsep 4\p@ plus2\p@ minus2\p@
\parsep 2\p@ plus\p@ minus\p@
\itemsep \parsep
}%
\belowdisplayskip
\abovedisplayskip
\itshape Paul Isamber}
}%
{3}
Where did all this ``stuff'' come from? What macros are responsible? I recognize that several default values are reset, but I don't understand what is doing it. I Tried to retrace possible steps through the relevant commands, beginning with \chapter, \tableofcontents, \l@chapter, \addcontentsline, \contentsline, \@dottedtocline, \@chapter, and the elusive \@starttoc. But I just simply ran into blind alleys!
\protect\small
if you want to get\small
in the toc.