[texhax] \addcontentsline -- line added to TOC appears in wrong place. Why?
Niall Mansfield
texhax at uit.co.uk
Wed May 7 17:59:45 CEST 2008
- Using book.cls.
- Redefined \appendix, to add an "Appendixes" heading line to
the TOC, as follows:
\renewcommand\appendix{
\addcontentsline{toc}{chapter}{Appendixes} %% this is the new line
\par
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\gdef\@chapapp{\appendixname}%
\gdef\thechapter{\@Alph\c at chapter}}
When we run this on a .tex file of the form:
\chapter{Last chap}
...
\appendix
\chapter*{APX-1}
...
\chapter*{APX-2}
...
we get the "Appendixes" line in the wrong place.
The .toc file shows this:
\contentsline {chapter}{\numberline {A}APX-1}{53}
\contentsline {chapter}{Appendixes}{53}
\contentsline {chapter}{\numberline {B}APX-2}{57}
What's happening?
More information about the texhax
mailing list