Document ClassesDocument class for edited book?

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
vietnamica
Posts: 21
Joined: Thu Nov 19, 2009 6:00 am

Document class for edited book?

Post by vietnamica »

Hello:
I am preparing an edited book with my MikTeX 2.7. Usually, I use the book class. But `\def\chaptername{}' and `\def\thechapter{}' are not enough for my design of table of contents.

I want the table of content is as follows:

[title of chapter 1]
[the authors].................. 10
[title of chapter 2]
[the authors].................. 20
....

and the beginning of each chapter is as follows:
[title of chapter]
[the authors]
--bodytex--

Thank you very much for your supports and guides.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Document class for edited book?

Post by gmedina »

Hi,

the following code can give you some ideas to help you solve your problem. I defined the command \chapaut with a mandatory argument. The command must be used right after the \chapter commands; the mandatory argument will be used for the names of the authors of the corresponding chapter. The command includes the names after the chapter name and also includes the names in the ToC. I also used the titlesec and titletoc packages to fine tune the chapter headings and the ToC entries.

Code: Select all

\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}
Of course, feel free to modify my example according to your needs.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
vietnamica
Posts: 21
Joined: Thu Nov 19, 2009 6:00 am

Document class for edited book?

Post by vietnamica »

Thank you very much gmedina. It works well. Then how can I align chaptertitle (in the body text) in center as well as change the font of chaptertitle?

I tried the followings but it presents no good.

Code: Select all

\begin{center}
\chapter{The first}
\chapaut{{\it 1st author \& 2dn author}}
\end{center}
vietnamica
Posts: 21
Joined: Thu Nov 19, 2009 6:00 am

Document class for edited book?

Post by vietnamica »

Code: Select all

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\filcenter}{}{20pt}{\Huge}[\addvspace{5pt}]
    \titlespacing*{\chapter}
    {0pt}{10pt}{0pt}
\titlecontents{chapter}
  [0pt]{\addvspace{10pt}}{\bfseries}{\bfseries}{}
The \filcenter solves my problem. Thank you all.
gvw0139
Posts: 1
Joined: Tue Mar 13, 2018 12:25 am

Document class for edited book?

Post by gvw0139 »

This solution works fine, but if faces a problem for me: in the TOC I only want the title of the chapter and its author, not the (sub)sections in the paper. If I add the command \setcounter{tocdepth}{0}, the (sub)sections disappear from the TOC, as required, but so does the chapter author name. Is there a way of getting rid of (sub)sections in the TOC while keeping the author name?
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Document class for edited book?

Post by rais »

gvw0139 wrote:Is there a way of getting rid of (sub)sections in the TOC while keeping the author name?
simply shift the authors-entry to chapter level

Code: Select all

\makeatletter
   \newcommand*\l@authors{\@dottedtocline{0}{0pt}{0pt}}
\makeatother
then the authors won't disappear from TOC with tocdepth set to 0.
Or, if you later want two versions, say one with authors in TOC and one without, leave \l@authors on level 1, shift the entry level for section to 2 and set tocdepth to 1 for keeping the authors in TOC:

Code: Select all

\setcounter{tocdepth}{1}
\makeatletter
   \newcommand*\l@authors{\@dottedtocline{1}{0pt}{0pt}}
   \renewcommand*\l@section{\@dottedtocline{2}{0pt}{0pt}}
\makeatother
KR
Rainer
Post Reply