19

I am preparing a book in which each chapter is contributed by different people.I want to include their name after the chapter title.How to I do it.If I use \maketitle it is useing the title and author name for the book. Here is the MWE:

\documentclass[12pt]{book}
\usepackage{lipsum}
\author{S.Subham Soni}
%\title{A Sample Test} --> I don't want to use this
\begin{document}
%\maketitle
\chapter{This is a test}
\lipsum[4]
\end{document}
lockstep
  • 250,273
subham soni
  • 9,673

2 Answers2

35

Why don't define a new command \chapterauthor

\makeatletter
\newcommand{\chapterauthor}[1]{%
  {\parindent0pt\vspace*{-25pt}%
  \linespread{1.1}\large\scshape#1%
  \par\nobreak\vspace*{35pt}}
  \@afterheading%
}
\makeatother

and use it in this way?

\documentclass[12pt]{book}
\usepackage{lipsum}

\makeatletter
\newcommand{\chapterauthor}[1]{%
  {\parindent0pt\vspace*{-25pt}%
  \linespread{1.1}\large\scshape#1%
  \par\nobreak\vspace*{35pt}}
  \@afterheading%
}
\makeatother

\begin{document}

\chapter{This is a test}
\chapterauthor{S.Subham Soni}

\lipsum[4]

\end{document} 

enter image description here


EDIT

Just in case you want to add authors' info in the ToC, here is a different version.

Use the starred version of \chapterauthor (\chapterauthor*) in correspondence of starred chapters (\chapter*).

MWE

\documentclass[12pt]{book}
\usepackage{lipsum}

\usepackage{suffix}

\newcommand\chapterauthor[1]{\authortoc{#1}\printchapterauthor{#1}}
\WithSuffix\newcommand\chapterauthor*[1]{\printchapterauthor{#1}}

\makeatletter
\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}%
}
\makeatother

\begin{document}
\tableofcontents

\chapter{1st chapter}
\chapterauthor{K.DINESH KUMAR \\ II Year B.Tech CSE}
\lipsum[1]

\section{A section}
\lipsum[1]

\chapter{2nd chapter}
\chapterauthor{S.Subham Soni}
\lipsum[1]

\section{A section}
\lipsum[1]

\chapter*{3rd chapter}
\chapterauthor*{Unknown}
\lipsum[1]
\end{document} 

Output (ToC):

enter image description here

karlkoeller
  • 124,410
  • You may wan to make it more advanced such that ht author can also be added to the TOC – daleif Jan 31 '14 at 16:24
  • \chapterauthor{K.DINESH KUMAR \par II Year B.Tech CSE} when I use this , I want enough spacing, How do I that? – subham soni Jan 31 '14 at 16:57
  • @subhamsoni I've edited the answer, change the value of \linespread if you want more spacing. Note that now you can use either \par or \\ inside \chapterauthor – karlkoeller Jan 31 '14 at 17:15
  • Thank you for this! I'd like the author names in the Table of Contents page to be of bigger font. How can I achieve that? – Arundhathi Mar 10 '16 at 16:33
  • 1
    @Arundhathi In the definition of \authortoc change \scriptsize to \large, for example. – karlkoeller Apr 10 '16 at 09:40
  • That's a really nice code @karlkoeller ! Is it possible though to make the author name not fully capital letter ? – Pierre Oct 24 '16 at 16:08
  • sorry, i finally found it: the environment ??shape allows to define the shape of your letters, so "sc" for small capitals. I replaced it with "up" (for upright) and it worked : \upshape#1 – Pierre Oct 25 '16 at 08:52
  • Is there an quick fix to prevent page breaks in the ToC between the chapter title and the authors? – sheß Dec 19 '19 at 14:33
  • By using \hskip1.3em in authortoc, the author name is not properly aligning with the chapter title. So, I have put \hskip1.5em instead. – raf May 26 '21 at 11:35
3

Not a solution, but idea on how to proceed

\author{....}
\title{...}
\makechaptertitle
\label{chap:key}

to start a chapter. Then \makechapter title could call \chapter and whatever else you need.

daleif
  • 54,450
  • It's an interesting idea, but I'm not sure to understand how it works. I'm thinking in a chapter with own author and show also the institution and the e-mail, so could I use your idea for that and how? – Aradnix Apr 24 '17 at 01:45