If you have to force a line break in a chapter title, this would be possible doing so:
\chapter[][A Long title that has to be broken,\\ how sad is this!]
But in my document I had to define my own chapter command, in order to have a chapter author and a subtitle:
\newcommand\Chapter[3][]{%
% Last char of the title
\StrRight{#2}{1}[\lastchar]%
% Put to \
\chapter[#2%
% We want a point in the ToC between title and subtitle
\if\relax\detokenize{#3}\relax%
\else%
% But not if there is a ?
\if\lastchar? %
\else%
% Or a !
\if\lastchar! %
% If not set a point
\else%
. %
\fi%
\fi%
\fi%
#3]{#2\\[2ex]\Large\Large#3}
\chaptermark]{\markboth{%
\if\relax\detokenize{#1}\relax #2%
\else #1\fi }{}%
}}
This works as expected, but not with a line break:
\Chapter[A Long title]{A Long title that has to be broken,\\ how sad is this!}{Some boring subtitles}
With the line break I get an error:
! Paragraph ended before \@firstoftwo was complete.
<to be read again>
\par
l.2 ...how sad is this!}{}
I suspect you've forgotten a `}', causing me to apply this
How ever, the line break works, but on the page before there appears the part after the line break on an extra page. What did I wrong?
Here is a complete working example:
\documentclass[10pt,twoside]{memoir}
\usepackage{xstring}
\usepackage{fontspec}
\usepackage{xltxtra}
\newcommand{\chapterauthor}
\renewcommand*{\cftchapterdotsep}{\cftdotsep}
\settocdepth{chapter}
\renewcommand{\cftchapterfont}{\normalfont}
\renewcommand{\cftchapterpagefont}{\normalfont}
\makeatletter
\DeclareRobustCommand\authortoctext[1]{%
{\addvspace{10pt}\nopagebreak\setlength{\parindent}{0em}\relax
\rightskip \@tocrmarg\relax
\itshape#1\par\addvspace{-7pt}}}
\makeatother
\newcommand\authortoc[1]{\needspace{3\baselineskip}%
\gdef\chapterauthor{#1}%
\addtocontents{toc}{\authortoctext{%
\needspace{2\baselineskip}% Vgl. http://tex.stackexchange.com/questions/134016
#1}}}
\renewcommand{\afterchaptertitle}{%
\vskip\onelineskip\begin{large}\normalfont\textit{\Large\chapterauthor}\end{large}
\vspace{4ex}
\vskip\onelineskip}
\newcommand\testchain[1]{%
\StrRight{#1}{1}[\lastchar]%
\IfStrEq{\lastchar}{?}{false}{true}%
}
\newcommand\Chapter[3][]{%
% Last char of the title
\StrRight{#2}{1}[\lastchar]%
% Put to \
\chapter[#2%
% We want a point in the ToC between title and subtitle
\if\relax\detokenize{#3}\relax%
\else%
% But not if there is a ?
\if\lastchar? %
\else%
% Or a !
\if\lastchar! %
% If not set a point
\else%
. %
\fi%
\fi%
\fi%
#3]{#2\\[2ex]\Large\Large#3}
\chaptermark]{\markboth{%
\if\relax\detokenize{#1}\relax #2%
\else #1\fi }{}%
}}
\begin{document}
\tableofcontents*
\Chapter[A Long title]{A Long title that has to be broken,\\ how sad is this!}{Some boring subtitles}
\end{document}

