3

I'm editing a book written by different authors, each chapter one or several authors. I would like to include the name of the authors of each chapter in the ToC, and also in the headers.

The answer from karlkoeller to the question Displaying author for each chapter in book explain a method to include the authors in the ToC. I would like to modify this method a little bit in order to be able to print them in the headers.

Here is my Minimal NotWorking Example:

\documentclass[11pt,portuges]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[paperwidth=17cm,paperheight=24cm]{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{lipsum}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\makeatletter
\newcommand\thechapterauthor[1]{}
\newcommand\chapterauthor[1]{\authortoc{#1}\printchapterauthor{#1}}
\newcommand{\printchapterauthor}[1]{%
  {\parindent0pt\vspace*{-25pt}%
  \linespread{1.1}\large\scshape#1%
  \par\nobreak\vspace*{35pt}}
  \@afterheading}
\newcommand{\authortoc}[1]{%
  \addtocontents{toc}{\vskip-10pt}%
  \addtocontents{toc}{%
    \protect\contentsline{chapter}%
    {\hskip1.3em\mdseries\scshape\protect\scriptsize#1}{}{}}
  \addtocontents{toc}{\vskip5pt}}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\textbf{\leftmark}}
\fancyhead[RE]{\thechapterauthor}
\makeatother   

\begin{document}
\frontmatter
\title{Título}
\author{Autor}
\maketitle
  \section*{Limiar}
    \lipsum[2-4]
\tableofcontents{}

\mainmatter
  \chapter{Chapter 1}
    \chapterauthor{Zê Povinho}
     \lipsum[1]
  \section{Section 1}
    \lipsum[1-8]
   \section{Section 2}
     \lipsum[3-7]
  \chapter{Chapter 2}
    \chapterauthor{L. Nemsei, P. Quemsabe}
     \lipsum[3-4]
  \section{Section 3}
     \lipsum[2-5]
  \subsection{Subsection 1}
     \lipsum[5-8]
\end{document}

Pdflatex does not print any warnings or errors, but the name of the authors does not appear in the headers. What to do?

  • 1
    Don't show only some snippets, create a small, complete example that demonstrates the problem. That makes it much easier to test. – Ulrike Fischer Dec 21 '18 at 16:31
2

It is sufficient to make \chapterauthor to define \thechapterauthor:

\newcommand\thechapterauthor{} % initialize
\newcommand\chapterauthor[1]{%
  \authortoc{#1}\printchapterauthor{#1}%
  \renewcommand\thechapterauthor{#1}%
}

enter image description here

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.