Document ClassesModifying a Macro Given in a Template, to alter TOC

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
hlc54
Posts: 2
Joined: Wed Jun 22, 2022 6:35 pm

Modifying a Macro Given in a Template, to alter TOC

Post by hlc54 »

I download the book template https://authorservices.wiley.com/asset/ ... s_v3.0.zip

The style file contains a defintion for the chapter foreword,

Code: Select all

\def\foreword{\startonoddpage
\chapter*{Foreword}
\global\titletrue
\addtocontents{toc}{\vskip-8pt}
\addcontentsline{toc}{schapter}{Foreword}}

\let\endforeword\endpreface

\def\l@schapter#1#2{%
  \ifnum \c@tocdepth >1
    \addpenalty{-\@highpenalty}%
    \vskip 6pt \@plus\p@
     \setlength\@tempdima{2.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode
      \advance\leftskip\@tempdima
      \hskip -\leftskip
#1\nobreak\hfil \nobreak\hbox
to\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
\vskip1sp
  \fi}
Which get called as,

Code: Select all

\begin{document} 
\include{foreword1}
\include{foreword2}
\end{document} 
where

Code: Select all

\begin{foreword}
\large{by Joe Bloggs},\\
\lipsum[1-2]
\end{foreword} 
When this compiles, the TOC says
Foreword xi
Foreword xiii
And I want it to say
Foreword (Joe Bloggs) xi
Foreword (Henry Blah) xiii
How can I modify the macro in the style file, such that I can change what is shown in the TOC? Thank you!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply