[texhax] trying to modify book.cls to automatically add TOC entry for \chapter* gives errors
Barbara Beeton
bnb at ams.org
Wed May 7 18:58:14 CEST 2008
On Wed, 7 May 2008, Niall Mansfield wrote:
- Using book.cls
- Want to change \chapter*{} in order to:
* add a TOC entry
* set the running heads
so that we can use \chapter*{} for Preface, Foreword,
Glossary, etc.
The definition we took from book.cls is, after simplifying:
\def\@schapter#1{
\@makeschapterhead{#1}%
\@afterheading}
If we change that to do either of the things we want, e.g.:
\def\@schapter#1{
\@makeschapterhead{#1}%
\@afterheading
\addcontentsline{toc}{chapter}{#1}}
we get error:
! TeX capacity exceeded, sorry [input stack size=300].
\originalTeX ->\noextrasenglish
\let \originalTeX \@empty \lefthyphenmin =2\...
l.1 \select at language {english}
or, if we clear out the existing .toc file first, we get:
No file authdns.toc.
[1
! Undefined control sequence.
\\->\let \reserved at e
\relax \let \reserved at f \relax \@ifstar {\let \reserved...
l.60 \listoftables
However, if we change the added line to:
\addcontentsline{toc}{chapter}{foobar}
then it "works", i.e. runs without error, but it's useless
of course. The same pattern happens when we try to insert
\mkboth{#1}{#1}
into \@schapter.
i'm not really conversant with how book.cls
does its toc insertions, but the amsbook.cls
does put the starred chapters into the t-of-c.
you might be able to crib some code from that.
I assume I'm doing something stupid, but I'm so confused
after trying this for hours that I can't think how to
start tracking it down. Help!
i've also seen your other message about adding
"Appendices" in the t-of-c. i think your best
bet there is to use something like this:
\addcontentsline{toc}{part}{Appendices}
alternatively, you could try entering all the
gory details:
\addtocontents{toc}{\protect\contentsline{part}%
{\protect\tocpart{}{}{Appendices}}{}
with amsbook, this would give just the heading,
with no page number; i'm not sure how book.cls
will react to this.
good luck.
-- bb
More information about the texhax
mailing list