Document ClassesAppendix section in TOC

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
blstzus
Posts: 4
Joined: Tue Nov 16, 2010 2:21 am

Appendix section in TOC

Post by blstzus »

Hi,
Me and a friend are trying to have our own class file for our university's thesis (adopted from book and another university's class). However, we encounter a problem with Appendix in TOC.

The format for our theis requires the TOC to be as:

CHAPTER I INTRO
1.1 first chapter
1.1.1 subsection
APPENDICES
A name of appendix A chapter
B name of appendix B chapter

The focus is on the appendices part. As you can see, the TOC will only include the appendix chapter name, without the section name. I believe the code below in the class file controls the TOC for chapters.

Code: Select all

\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \setlength\@tempdima{3.75em}% nadzir set \numberline{} width
    \begingroup
      \parindent \toc@sep@chap %\z@ Nadzir centered the chapter number instead of 0em
      \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\normalfont \hss #2}\par
      \penalty10000% to discourage chapter to appear at last line of page
    \endgroup
  \fi}

\def\@chapter[#1]#2{%
  \ifnum \c@secnumdepth >\m@ne
     \if@mainmatter
       \refstepcounter{chapter}%
       \typeout{\@chapapp\space\thechapter.}%
       \if@appendix
       \addtocontents{toc}{\protect\addvspace{\@twolinespacing}}%
         \addcontentsline{toc}{section}%
         {\protect\numberline{\hspace*{2.5em}\thechapter}\hspace*{2.5em}\space\MakeUppercase{#1}}            

\hspace*(3.8em)\space\MakeUppercase{#1}}
         %dummy label to make Lampiran in toc possible
         \label{applastpage}
       \else
         \addtocontents{toc}{\protect\addvspace{\@twolinespacing}}%
         \addcontentsline{toc}{chapter}{\protect\numberline{\chaptername\space\thechapter}\hspace*{3.8em}\space\MakeUppercase{#1}}%
         \fi
     \else
       \addcontentsline{toc}{nonmainmatterchapter}{\MakeUppercase{#1}}%
     \fi
  \else
    \addcontentsline{toc}{chapter}{\MakeUppercase{#1}}%
  \fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10\p@}}%
  \addtocontents{lot}{\protect\addvspace{10\p@}}%
  \if@twocolumn
    \@topnewpage[\@makechapterhead{\MakeUppercase{#2}}]%
  \else
    \@makechapterhead{\MakeUppercase{#2}}%
    \@afterheading
  \fi}
I tried using

Code: Select all

\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
after \if@appendix command in the above code (line 22 above). But that doesn't work and will make all the list of figures and tables empty.

Did I do that wrongly? Is there a way that I can make the appendix sections not to appear in TOC?

Thank you.

-Aiman-

p/s: I attach the complete class file (named unitenthesis) that we are trying to create, just in case the above code is insufficient.
Attachments
unitenthesis.cls
unitenthesis class file
(48.22 KiB) Downloaded 232 times

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