2

I want the chapter's author name being shown in the ToC. So 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} 

\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 

% Page style
\makepagestyle{mystyle}
\makeevenhead{mystyle}{\thepage}{\small\chapterauthor}{}
\makeoddhead{mystyle}{}{\slshape\leftmark}{\thepage}
\pagestyle{mystyle}

%%
% Inhaltsverzeichnis
%%
\renewcommand*{\cftchapterdotsep}{\cftdotsep}
\settocdepth{chapter}
\renewcommand{\cftchapterfont}{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont}

\makeatletter
\DeclareRobustCommand\authortoctext[1]{%
{\addvspace{10pt}\nopagebreak\leftskip0em\relax
\rightskip \@tocrmarg\relax
\noindent\itshape#1\par\addvspace{-7pt}}}
\makeatother
\newcommand\authortoc[1]{%
  \gdef\chapterauthor{#1}%
  \addtocontents{toc}{\authortoctext{#1}}}

%%
% Dokumentenbeginn
%%
\begin{document}
\tableofcontents* 
\authortoc{Walter von der Vogelweide}
\chapter{Ich sass uf eynem Steine?}
\section{Und dachte Bein mit Beine}
\Blindtext\Blindtext\Blindtext\Blindtext

\authortoc{Hartman von Aue}
\chapter[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalitat}
\Blindtext\Blindtext\Blindtext\Blindtext
\end{document}

Everything works as expected, but I have the problem that sometimes author's name and chapter's title are split up by the page break. So that the first become an orphan and the latter a widow. How to avoid that?

2
  • Load the needspace package and add a line \addtocontents{toc}{\needspace{2em}}% before \addtocontents{toc}{\authortoctext{#1}}} in the definition of \authortoc. Commented Sep 19, 2013 at 6:00
  • 1
    @karlkoeller See answer below. Your fix did not actually work, though like you, I thought it would have. Commented Sep 20, 2013 at 5:27

1 Answer 1

2

I would have thought Karl Koeller's comment would have worked, but it did not seem to. What did work is shown below, in which \needspace{2\baselineskip} is added within the argument to \authortoctext, prior to #1.

In this MWE, I changed the textheight to reproduce the problem when the remedy is not implemented.

\documentclass[10pt,twoside]{memoir}
\textheight=10.5cm
\usepackage[german]{babel}
\usepackage{blindtext}
\usepackage[ansinew]{inputenc} 
\usepackage{setspace}% NEED THIS PACKAGE

\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 

% Page style
\makepagestyle{mystyle}
\makeevenhead{mystyle}{\thepage}{\small\chapterauthor}{}
\makeoddhead{mystyle}{}{\slshape\leftmark}{\thepage}
\pagestyle{mystyle}

%%
% Inhaltsverzeichnis
%%
\renewcommand*{\cftchapterdotsep}{\cftdotsep}
\settocdepth{chapter}
\renewcommand{\cftchapterfont}{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont}

\makeatletter
\DeclareRobustCommand\authortoctext[1]{%
{\addvspace{10pt}\nopagebreak\leftskip0em\relax
\rightskip \@tocrmarg\relax
\noindent\itshape#1\par\addvspace{-7pt}}}
\makeatother
\newcommand\authortoc[1]{\needspace{3\baselineskip}%
  \gdef\chapterauthor{#1}%
  \addtocontents{toc}{\authortoctext{%
    \needspace{2\baselineskip}%  <THIS IS THE ADDED LINE
  #1}}}

%%
% Dokumentenbeginn
%%
\begin{document}
\tableofcontents* 
\authortoc{Walter von der Vogelweide}
\chapter{Ich sass uf eynem Steine?}
\section{Und dachte Bein mit Beine}
\Blindtext\Blindtext\Blindtext\Blindtext

\authortoc{Hartman von Aue}
\chapter[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalitat}
\Blindtext\Blindtext\Blindtext\Blindtext

\authortoc{Hartman von Aue}
\chapter[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalitat}
\Blindtext\Blindtext\Blindtext\Blindtext

\authortoc{Hartman von Aue}
\chapter[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalitat}
\Blindtext\Blindtext\Blindtext\Blindtext

\authortoc{Hartman von Aue}
\chapter[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalitat}
\Blindtext\Blindtext\Blindtext\Blindtext

\authortoc{Hartman von Aue}
\chapter[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalitat}
\Blindtext\Blindtext\Blindtext\Blindtext

\authortoc{Hartman von Aue}
\chapter[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalitat}
\Blindtext\Blindtext\Blindtext\Blindtext

\authortoc{Hartman von Aue}
\chapter[Was auch immer]{So gebt nur mehr und immer mehr}
\section{Moralische Quellen der Irrationalitat}
\Blindtext\Blindtext\Blindtext\Blindtext
\end{document}
2
  • This works pretty well, but can anybody tell me, why the author's name get's an indent and how to avoid that? Sorry for the stupid question, I am a beginner.
    – user5950
    Commented Sep 24, 2013 at 20:52
  • 1
    @user5950 The definition of \authortoctext needs to have some \leftskip in order to align with the chapter number rather than the chapter name. For example, here I shift 1.7em to the left: \DeclareRobustCommand\authortoctext[1]{% {\addvspace{10pt}\nopagebreak\leftskip-1.7em\relax \rightskip \@tocrmarg\relax \noindent\itshape#1\par\addvspace{-7pt}}} Commented Sep 24, 2013 at 23:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .