LaTeX forum ⇒ Document ClassesDocument class for edited book?

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

Document class for edited book?

Postby vietnamica » Thu Nov 19, 2009 6:16 am

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.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Postby gmedina » Sat Nov 21, 2009 2:46 am

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.

  1. \documentclass{book}
  2. \usepackage{titlesec}
  3. \usepackage{titletoc}
  4. \usepackage{lipsum}% just to generate some text
  5.  
  6. \makeatletter
  7. \newcommand*\l@authors{\@dottedtocline{1}{0pt}{0pt}}
  8. \makeatother
  9. \newcommand\chapaut[1]{%
  10. \addcontentsline{toc}{authors}{#1}%
  11. {\bfseries#1}\vskip35pt}
  12.  
  13. \titleformat{\chapter}[display]
  14. {\normalfont\huge\bfseries}{}{20pt}{\Huge}[\addvspace{5pt}]
  15. \titlespacing*{\chapter}
  16. {0pt}{10pt}{0pt}
  17. \titlecontents{chapter}
  18. [0pt]{\addvspace{10pt}}{\bfseries}{\bfseries}{}
  19.  
  20. \begin{document}
  21. \tableofcontents
  22.  
  23. \chapter{Test chapter one}
  24. \chapaut{The name of the first author, The name of second author and The name of the third author}
  25. \lipsum[1-20]
  26.  
  27. \chapter{Test chapter two}
  28. \chapaut{The First author and The second author}
  29. \lipsum[1-20]
  30.  
  31. \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

Postby vietnamica » Sat Nov 21, 2009 5:06 am

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.
  1. \begin{center}
  2. \chapter{The first}
  3. \chapaut{{\it 1st author \& 2dn author}}
  4. \end{center}

vietnamica
Posts: 21
Joined: Thu Nov 19, 2009 6:00 am

Postby vietnamica » Sat Nov 21, 2009 5:23 am

  1. \titleformat{\chapter}[display]
  2. {\normalfont\huge\bfseries\filcenter}{}{20pt}{\Huge}[\addvspace{5pt}]
  3. \titlespacing*{\chapter}
  4. {0pt}{10pt}{0pt}
  5. \titlecontents{chapter}
  6. [0pt]{\addvspace{10pt}}{\bfseries}{\bfseries}{}


The \filcenter solves my problem. Thank you all.

gvw0139
Posts: 1
Joined: Tue Mar 13, 2018 12:25 am

Postby gvw0139 » Tue Mar 13, 2018 12:30 am

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: 177
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Tue Mar 13, 2018 8:43 am

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
  1. \makeatletter
  2. \newcommand*\l@authors{\@dottedtocline{0}{0pt}{0pt}}
  3. \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:
  1. \setcounter{tocdepth}{1}
  2. \makeatletter
  3. \newcommand*\l@authors{\@dottedtocline{1}{0pt}{0pt}}
  4. \renewcommand*\l@section{\@dottedtocline{2}{0pt}{0pt}}
  5. \makeatother

KR
Rainer


Return to “Document Classes”

Who is online

Users browsing this forum: No registered users and 3 guests