I working on an edition with various author. And I want the chapter's author name being shown in the ToC. I have modified the chapter to add the author there and use it in the page header as follows:
\documentclass[10pt,twoside]{memoir}
\usepackage[german]{babel}
\usepackage{blindtext}
\usepackage[ansinew]{inputenc}
\usepackage{scrpage2}
%%
% Kopf- und Fußzeile
%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter
%%
% Kapitelüberschrift um Feld für Autor erweitern
%%
\newcommand*{\orgichapter}{}
\let\orgichapter\chapter
\renewcommand*{\chapter}[1]{%
\gdef\chapterauthor{#1}%
\orgichapter
}
\renewcommand*{\chapterformat}{}
%%
% Kapitelüberschrift formatieren
%%
\renewcommand{\printchaptername}{} % Kapitelnamen unterdrücken
\renewcommand{\chapternamenum}{}
\renewcommand{\printchapternum}{} % Kapitelnummer unterdrücken
\renewcommand{\afterchapternum}{}
%%
% Autor nach Titel einfügen
%%
\renewcommand{\afterchaptertitle}{%
\vskip\onelineskip\begin{large}\textit{\chapterauthor}\end{large}
\vskip\onelineskip}
%%
% Zählung auf der Ebene \section beginnen
%%
\renewcommand{\thesection}{\arabic{section}}
\setcounter{secnumdepth}{3} % Subsection mit Zähler (1.1) versehen
%%
% Kolumnentitel
%%
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} } % Stil der Kopfzeile zurücksetzen
\renewcommand{\sectionmark}[1]{ \markright{#1}{} } % Stil der Kopfzeile zurücksetzen
\fancyhf{} % Use fancyhdr
\fancyhead[CE]{\small\chapterauthor} % L for Left, E for Even page
\fancyhead[CO]{\small\leftmark} % Aufsatztitel als Kolumentitel
%\fancyhead[CO]{\rightmark} % \chapter als Kolumnentitel
\fancyhead[LE]{\thepage} % L for Left, E for Even page
\fancyhead[RO]{\thepage}
\renewcommand{\headrulewidth}{0pt} % Keine Trennlinie
%%
% Inhaltsverzeichnis
%%
\renewcommand*{\cftchapterdotsep}{\cftdotsep}
\settocdepth{chapter}
\renewcommand{\cftchapterfont}{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont}
%%
% Dokumentenbeginn
%%
\begin{document}
\tableofcontents*
\chapter{Walter von der Vogelweide}[]{Ich saß uf eynem Steine?}
\section{Und dachte Bein mit Beine}
\Blindtext
\clearpage
\chapter{Hartman von Aue}[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalität}
\thispagestyle{empty}
\Blindtext
\section{Das ist nur Blindtext}
\Blindtext
\end{document}
How can I use the \chapterauthor
now in ToC? It should look like this:
Walter von der Vogelweide
Title of the chapter ........ 123
Hartmann von Aue
Title of the chapter ........ 345
I know, many have asked that before, but I can't get it working anyhow.
Best Answer
I would suggest you not to overload the standard commands. In the following example I defined a command
\authortoc
to be used before each\chapter
; this commands includes its argument in the table of contents (I chose italicized font, but you can easily change this) and also makes provision for the marks to be used in the headers.I also used
\makepagestyle
and its family of associated commands to define the page style (memoir
has its own mechanism to define page styles so it's not necessary (nor advisable) to usefancyhdr
):Here's an image of the resulting ToC:
I suppressed code from the original example that was not relevant for the problem mentioned. I also changed the spelling og some German words just for the example (I felt lazy about changing the encoding of my editor),