2

I want to include the author name before the chapter title. I am using the following:

\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{lipsum}% just to generate some text

\makeatletter
  \newcommand*\l@authors{\@dottedtocline{1}{0pt}{0pt}}
\makeatother
\newcommand\chapaut[1]{%
  \addcontentsline{toc}{authors}{#1}%
  {\bfseries#1}\vskip35pt}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{}{20pt}{\Huge}[\addvspace{5pt}]
\titlespacing*{\chapter}
  {0pt}{10pt}{0pt}
\titlecontents{chapter}
  [0pt]{\addvspace{10pt}}{\bfseries}{\bfseries}{}

\begin{document}
\tableofcontents

\chapter{Test chapter one}
\chapaut{The name of the first author, The name of second author and The name of the third author}
\lipsum[1-20]

\chapter{Test chapter two}
\chapaut{The First author and The second author}
\lipsum[1-20]

\end{document}

I want to change chapter with chapaut, so it will look like:

enter image description here

Also, in the table of contents:

enter image description here

15
  • drives me nuts, not sure want you mean. Can you please show me a code example – mvp285286 May 29 '16 at 7:18
  • Is the problem resolved? – Runar May 29 '16 at 20:51
  • thank you for your example. But my problem isn't solved yet. Your code is good, but very complex :-) Is it possible to change my code, I just want to change the chapter with the author name like the img above – mvp285286 May 30 '16 at 14:30
  • I simplified the code, removed some unused packages and some other code, and added a lot of comments to make sense of the code. Does it help? – Runar May 30 '16 at 20:55
  • awesome! thx, it works fine – mvp285286 May 31 '16 at 9:49
5

if I understand you correctly, you want to achieve two things:

In the Tabel of Contents, you would like the author(s) of that chapter to be listed before the title of the chapter.

When the chapter is printed, you would also here, like to have the author(s) before the chapter title.

I think this might help, but I do believe there is a better way to do it, than this, especially for the ToC.

One other way to print the authors on top of the chaptertitle in the text, might be to change the definition of \chapter, but sometimes changing the definition of certain commands might have unforeseen sideeffects, so only do that if you know what you are doing. This question might be of interest: Start new chapter on same page.

EDIT: Really long chaptertitles, spanning multiple lines in the toc, will now be indentet on every line, instead of only the first.

\documentclass{book}
\usepackage{titletoc}
\usepackage{lipsum}% just to generate some text

% This part changes how chapters are displayed in the Table of COntents
\titlecontents{chapter}
  [0pt]% Left margin, optional
  {}% Code insertet above
  {\bfseries}% Numbered-entryformat
  {\bfseries}% Numberless-format
  {\contentspage\vskip1.5ex} %Below code, here: add dotfill and pagenumber for entry, and some vertical space between entries

% Custom command to keep the author on the same page of chaptertitle, and above it.  
\newcommand{\chapterAndAuthor}[2]{%
 % Takes the following input
 % #1: Author
 % #2: Chaptertitle
\clearpage%
    % Minipage to keep the author and chaptertitle on same page
    \noindent\begin{minipage}{\textwidth}
        % Set the author style
        {\bfseries#1}
        % Bring the chaptertitle a bit closer to the authrotitle
        \vspace{-3\baselineskip}
        % Add an entry to the Table of Contents, with the name of the author in italics and the chapter title
        \addcontentsline{toc}{chapter}{{\normalfont\itshape #1}\vspace{1ex}\newline%
        %To make long chapter titles spanning multiple lines indent on each line, a \parbox is created. This is siimply a box holding a wrapped paragraph at a certain length. Also, we need to move the dotfill here.
        \hspace*{1em}\protect{\parbox[b]{\textwidth}{#2 \dotfill}}}
        % Print the chapter
        \chapter*{#2}
    \end{minipage}
    }

\begin{document}
\tableofcontents

\clearpage

\chapterAndAuthor{The name of the first author, The name of second author and The name of the third author}{Test Chapter One is really long, and I wouldn't really bother to read it as I am falling asleep}

\lipsum[1-20]

\chapterAndAuthor{John Doe}{Test Chapter Two}
\lipsum[1-20]

\end{document}

enter image description here Chapter title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.