1

I found these answers really helpful to add different authors' names to chapters to the toc:

Add author before chapter title in ToC

I included

\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}}}

into my code, compiled with lualatex, and it worked out.

But when it comes to longer articles' titles, the next line has an indent.

See here:

\documentclass[paper=a4,DIV=11,12pt,headings=small,titlepage]{scrbook}
\usepackage{fontspec}
\usepackage[english,ngerman]{babel}
\setcounter{tocdepth}{0}
\renewcommand*\thesection{\arabic{section}}
\usepackage{xpatch}
\xpretocmd{\addchap}{\setcounter{section}{0}}{}{}

\renewcommand*\chapterheadstartvskip{\vspace*{-\topskip}}
\renewcommand*\chapterheadendvskip{%
 \vspace*{1\baselineskip plus .1\baselineskip minus .200\baselineskip}}
%\usepackage{url}
\setkomafont{sectioning}{\rmfamily\normalfont} 
%\addtokomafont{chapter}{\large}
%\addtokomafont{section}{\normalsize\textbf}
\addtokomafont{subsection}{\normalsize\textbf}
\addtokomafont{subsubsection}{\normalsize}
\usepackage{blindtext}
 \usepackage{tocloft}
    \renewcommand\cftchappagefont{\normalfont}  % nicht fett
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}

\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}}}

\begin{document}

\makeatletter
 \renewcommand\tableofcontents{\@starttoc{toc}}
  \makeatother
 \section*{\Large Inhaltsverzeichnis \vskip 5mm}
\tableofcontents
\thispagestyle{empty}

\authortoc{Martina Müller}
\addchap["`Was geht mich das an?"' -- Eine Einführung in den Begriff und das Denken dessen, was mich angeht oder nicht angeht]{\emph{Martina Müller} \\[1em] "`Was geht mich das an?"' -- \\ Eine Einführung in den Begriff und das Denken dessen, was mich angeht oder nicht angeht \vskip 6mm} 

\blindtext
\section{Betroffenheit}
\blindtext
\subsection{Aktives Betroffensein}
\blindtext
\subsection{Passives Betroffensein}
\blindtext
\section{Angenervt sein}
\blindtext

\authortoc{Marcus Schmidt}
\addchap[Butter bei die Fische. Zur Reduktion auf das Wesentliche]{\emph{Marcus Schmidt} \\[1em] Butter bei die Fische. \\ Zur Reduktion auf das Wesentliche \vskip 6mm}

\blindtext
\section{Fische und anderes Meeresgetier}
\blindtext
\addsec{\emph{Exkurs}: Sternzeichen}
\blindtext
\section{Warum Sternzeichen nerven}
\blindtext
\end{document}

Any ideas on how to suppress this indent? Thank you so much!

Franzi
  • 35
  • I don't use LuLaTeX so forgive me if this question is stupid, but does \noindent at the place were the undesired indent is solve your problem? May be this question provides further help too. – SeverinBang Jul 15 '16 at 12:08
  • hey, no, \noindent doesn't work in \chapter[title in toc]{title in text}. this here was my first try without further renewcommands as \authortoc: \chapter[\emph{Marcus Schmidt} \ Title of his article for the toc]{large{\emph{Marcus Schmidt}} \[1em] Title of his gorgeous and stunning article in text \vskip 6mm} - this way, you get the title from the beginning with an indent (because of the \), whether or not you are using \noindent ... – Franzi Jul 15 '16 at 15:40

1 Answers1

1

You are using a KOMA-Script class. So here is a suggestion that needs an uptodate KOMA version (at least v. 3.21) but without tocloft.

Note that the next lines of numbered chapter TOC entries are also not indented. The reserved horizontal space for their chapter numbers is 1.5em, but this value can be adjusted if needed.

enter image description here

enter image description here

Code:

\documentclass[DIV=11,12pt,headings=small,titlepage,
  headings=optiontoheadandtoc
]{scrbook}[2016/06/14]
\usepackage{fontspec}
\usepackage[english,ngerman]{babel}
\usepackage{xpatch}

\setcounter{tocdepth}{0}
\renewcommand*\thesection{\arabic{section}}

\setkomafont{sectioning}{\rmfamily\normalfont}
\addtokomafont{chapterentry}{\normalfont}
\addtokomafont{subsection}{\normalsize\bfseries}
\addtokomafont{subsubsection}{\normalsize}
\newkomafont{chapterauthor}{\emph}
\makeatletter
\RedeclareSectionCommand[%
  beforeskip=-1sp,%
  afterskip=1.5\baselineskip plus .1\baselineskip minus .2\baselineskip,%
  tocentrynumberformat=\@gobble,
  tocnumwidth=0pt,
  toclinefill=\TOCLineLeaderFill,
  toconstarthigherlevel=\vspace{-.75\baselineskip}
]{chapter}


\DeclareTOCStyleEntry[{
  level=\parttocdepth,
  beforeskip=10pt,
  indent=0pt,
  numwidth=0pt,
  linefill=\hfill,
  entryformat=\textit,
  pagenumberbox=\@gobble
}]{tocline}{chapterauthor}

\newcommand*\@chapterauthor{}
\newcommand\chapterauthor[1]{\def\@chapterauthor{#1}}

\xpatchcmd{\addchaptertocentry}{%
    \addtocentrydefault{chapter}{#1}{#2}%
  }{%
    \ifstr{\@chapterauthor}{}{}{
      \addtocentrydefault{chapterauthor}{}{\@chapterauthor}%
    }%
    \ifstr{#1}{}
      {\addtocentrydefault{chapter}{#1}{#2}}
      {\addtocentrydefault{chapter}{}{\makebox[1.5em][l]{#1\autodot}#2}}%
  }{}{\PatCHFaiLED}

\renewcommand\chapterlinesformat[3]{%
  \ifstr{\@chapterauthor}{}{}{{\usekomafont{chapterauthor}\@chapterauthor}\\*[1em]}
  \@hangfrom{#2}{#3}%
  \xdef\@chapterauthor{}%
}
\makeatother

\usepackage{blindtext}
\begin{document}
\tableofcontents

\chapterauthor{Martina Müller}
\addchap[
    tocentry={"`Was geht mich das an?"' -- Eine Einführung in den Begriff und das Denken dessen, was mich angeht oder nicht angeht},
    head={"`Was geht mich das an?"'}
  ]
  {"`Was geht mich das an?"' -- \\ Eine Einführung in den Begriff und das Denken dessen, was mich angeht oder nicht angeht} 

\blindtext
\section{Betroffenheit}
\blindtext
\subsection{Aktives Betroffensein}
\blindtext
\subsection{Passives Betroffensein}
\blindtext
\section{Angenervt sein}
\blindtext

\chapterauthor{Marcus Schmidt}
\addchap[Butter bei die Fische. Zur Reduktion auf das Wesentliche]{Butter bei die Fische. \\ Zur Reduktion auf das Wesentliche}

\blindtext
\section{Fische und anderes Meeresgetier}
\blindtext
\addsec{\emph{Exkurs}: Sternzeichen}
\blindtext
\section{Warum Sternzeichen nerven}
\blindtext
\end{document}

If the class option headings=optiontotocandhead is set, an option author for the optional argument of \addchap or \chapter can be defined. Then you can use

\addchap[
    author={Author of the chapter},
    tocentry={TOC entry for this chapter},
    head={Running head for this chapter}
  ]{Chapter title}

Example:

\documentclass[DIV=11,12pt,headings=small,titlepage,
  headings=optiontoheadandtoc
]{scrbook}[2016/06/14]
\usepackage{fontspec}
\usepackage[english,ngerman]{babel}
\usepackage{xpatch}

\setcounter{tocdepth}{0}
\renewcommand*\thesection{\arabic{section}}

\setkomafont{sectioning}{\rmfamily\normalfont}
\addtokomafont{chapterentry}{\normalfont}
\addtokomafont{subsection}{\normalsize\bfseries}
\addtokomafont{subsubsection}{\normalsize}
\newkomafont{chapterauthor}{\emph}

\makeatletter
\RedeclareSectionCommand[%
  beforeskip=-1sp,%
  afterskip=1.5\baselineskip plus .1\baselineskip minus .2\baselineskip,%
  tocentrynumberformat=\@gobble,
  tocnumwidth=0pt,
  toclinefill=\TOCLineLeaderFill,
  toconstarthigherlevel=\vspace{-.75\baselineskip}
]{chapter}


\DeclareTOCStyleEntry[{
  level=\parttocdepth,
  beforeskip=10pt,
  indent=0pt,
  numwidth=0pt,
  linefill=\hfill,
  entryformat=\textit,
  pagenumberbox=\@gobble
}]{tocline}{chapterauthor}

\providecommand*\@currentauthor{}
\FamilyStringKey[.section]{KOMAarg}{author}{\@currentauthor}

\xpatchcmd{\addchaptertocentry}{%
    \addtocentrydefault{chapter}{#1}{#2}%
  }{%
    \ifstr{\@currentauthor}{}{}{
      \addtocentrydefault{chapterauthor}{}{\@currentauthor}%
    }%
    \ifstr{#1}{}
      {\addtocentrydefault{chapter}{#1}{#2}}
      {\addtocentrydefault{chapter}{}{\makebox[1.5em][l]{#1\autodot}#2}}%
  }{}{\PatCHFaiLED}

\renewcommand\chapterlinesformat[3]{%
  \ifstr{\@currentauthor}{}{}{{\usekomafont{chapterauthor}\@currentauthor}\\[1em]}
  \@hangfrom{#2}{#3}%
  \xdef\@currentauthor{}%
}

\xapptocmd\chapterlineswithprefixformat{\xdef\@currentauthor{}}{}{\PatchFailed}
\xapptocmd\sectionlinesformat{\xdef\@currentauthor{}}{}{\PatchFailed}
\xapptocmd\sectioncatchphraseformat{\xdef\@currentauthor{}}{}{\PatchFailed}
\makeatother

\usepackage{blindtext}
\begin{document}
\tableofcontents

\addchap[
    author={Martina Müller},
    tocentry={"`Was geht mich das an?"' -- Eine Einführung in den Begriff und das Denken dessen, was mich angeht oder nicht angeht},
    head={"`Was geht mich das an?"'}
  ]
  {"`Was geht mich das an?"' -- \\ Eine Einführung in den Begriff und das Denken dessen, was mich angeht oder nicht angeht} 

\blindtext
\section{Betroffenheit}
\blindtext
\subsection{Aktives Betroffensein}
\blindtext
\subsection{Passives Betroffensein}
\blindtext
\section{Angenervt sein}
\blindtext

\addchap[
  author={Marcus Schmidt},
  tocentry={Butter bei die Fische. Zur Reduktion auf das Wesentliche},
  head={Butter bei die Fische. Zur Reduktion auf das Wesentliche}
  ]{Butter bei die Fische. \\ Zur Reduktion auf das Wesentliche}

\blindtext
\section{Fische und anderes Meeresgetier}
\blindtext
\addsec{\emph{Exkurs}: Sternzeichen}
\blindtext
\section{Warum Sternzeichen nerven}
\blindtext

\chapter{Test}
\end{document}
esdd
  • 85,675
  • For some reason, I can't compile your code. Log is not found.. funny enough, I could run it before the updating, which you advised me. (thanks though for the hint). – Franzi Jul 15 '16 at 15:46
  • yeah! now, it works fine! (I had to build the formats after running the updates) Thanks a lot, @esdd !! – Franzi Jul 21 '16 at 16:39