1

I'm putting together a book (using the book class) where each chapter is written by a different author. So each chapter will have two lines of text, and so will each entry on the ToC. By default, LaTeX positions the page number right aligned, and next to the second line of the entry (which is the author, in my case) in the ToC.

I want it to be next to the right next to the entry (not right-aligned) and on the first line (i.e. right next to the chapter title). Something like this:

**Contents**

Chapter 1 title blah blah   5
Author 1

Chapter 2 title blah   11
Author 2

etc...

Here's a MWE:

\documentclass[twoside,10pt]{book}
\usepackage[hidelinks]{hyperref}

\usepackage{pdfpages}

\begin{document}

\cleardoublepage
\phantomsection %
\pdfbookmark[0]{\contentsname}{toc} % Adds a PDF bookmark for the TOC.

{\pagestyle{plain}
\tableofcontents
\cleardoublepage}

\chapter[Chapter 1 title Blah Blah \\{\normalfont Author 1}]{Chapter 1 title Blah Blah \\ {\normalfont Author 1}} 

Chapter 1 text.

....

\chapter[Chapter 2 title Blah \\ {\normalfont Author 2}]{Chapter 2 title Blah \\ {\normalfont Author 2}} 

Chapter 2 text ..
....

\end{document}

Thanks in advance for the help.

1

I'd suggest a different input. Define something like \chapterauthor{<title>}{<author>} where you specify the chapter title and author separately. Then you have each of these components that you can manage within the TeX workflow. That's what I've done below:

enter image description here

\documentclass{book}

\usepackage{lipsum}
\usepackage[hidelinks]{hyperref}

% \chapterauthor{<title>}{<author>}
\newcommand{\chapterauthor}[2]{%
  \chapter[#1]{#1 \\ \normalfont #2}% \chapter{<title>}
  \addtocontents{toc}{% Add author entry to ToC
    \nobreak\par{\normalfont #2\par}\nobreak}%
}

\begin{document}

\sloppy % For this example

\tableofcontents

\chapterauthor{First chapter}{Author 1}\lipsum[1-5]
\section{A section}\lipsum[1-5]

\chapterauthor{Second chapter}{Author 2}\lipsum[1-5]
\section{Another section}\lipsum[1-5]

\end{document}

The author is printed as part of the chapter title as well:

enter image description here

  • Thanks. I had completely forgotten of \addtocontents. That definitely answers one of my questions. As for the new command, I initially had something similar defined where I could specify author and title separately, but that caused me problem whenever I used pandoc to convert to epub(which I have to). Pandoc could not handle it, that's why I stuck to the default chapter command. – johnymm Jan 19 at 19:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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