Text FormattingAdding Appendix to Table of Contents

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
ucf_436
Posts: 6
Joined: Mon Jun 06, 2011 7:15 pm

Adding Appendix to Table of Contents

Post by ucf_436 »

Hi all,
I am trying to add appendices to the table of contents but it recognises it as chapters and hence calls them as chapters in the table of contents.

Code: Select all

  \def\appendix{\par
  \setcounter{chapter}{0}
  \setcounter{section}{0}
  \def\@chapapp{APPENDIX}
  \def\thechapter{\Alph{chapter}}}
This is how the code is now in the .clo file.

In the class file under the table of contents, I tried to add a section for appendices asking it to understand the difference between chapter and appendix by using chapapp (this has been defined before). The code I used is

Code: Select all

   \def\l@chapapp#1#2{\pagebreak[3]
   \vskip 1.0em plus 1pt  % space above chapter line
   \@tempdima 1.5em       % width of box holding chapter number
   \begingroup
   \parindent \z@ \rightskip \@pnumwidth
   \parfillskip -\@pnumwidth
     \bfseries                  % Boldface.
     \leavevmode          % TeX command to enter horizontal mode.
   APPENDIX#1\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfill\hbox to\@pnumwidth{\hfil #2}\par
   \endgroup}
However, this doesn't work either. It changed the heading of all the chapters in the table of contents to APPENDIX.

Any help regarding this would be greatly appreciated.
Thanks
Last edited by Stefan Kottwitz on Mon Jun 06, 2011 8:31 pm, edited 1 time in total.

Recommended reading 2024:

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

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

west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

Adding Appendix to Table of Contents

Post by west.logan »

Are you defining your own class? Or using Memoir (seems I remember chapapp in there).

In the Memoir class, you can use

Code: Select all

\endmatter
I believe, or the

Code: Select all

\appendix
command to turn chapters into appendices.

But without a MWE I don't have much to go on.
ucf_436
Posts: 6
Joined: Mon Jun 06, 2011 7:15 pm

Adding Appendix to Table of Contents

Post by ucf_436 »

We do define our own class. I have attached the class file here. There is also a .clo file which for some reason I am not able to attach here. They have defined the appendices as chapters and so when it appears in the table of contents, it calls it a chapter and not appendix. I have attached the sample .tex file in which the appendices have been defined.
Thanks for the help.
sample.tex
The sample tex file
(4.91 KiB) Downloaded 321 times
ucfthes.cls
The class file
(31.11 KiB) Downloaded 332 times
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

Re: Adding Appendix to Table of Contents

Post by west.logan »

I was able to find the class files on the UCF website. However, I'm getting an error when I run it. I just move past it but had a question:

In the ToC, I see "Chapter Chapter 1: W", where Chapter is repeated twice. It looks like it's also being added to the appendix so I see "Chapter Appendix A: F1"

Is this what you are getting? From the class definition, it looks like they are hard-coding the chapter, which is strange. I'm wondering if one of your packages is messing with the class.
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

Adding Appendix to Table of Contents

Post by west.logan »

Editing the .cls file and removing the hard-coded "CHAPTER" fixed the problem for me. I'm not sure if that's what you were asking though. This is the section. Just remove "CHAPTER" from it in the .cls file.

Code: Select all

\def\l@chapter#1#2{\pagebreak[3]
   \vskip 1.0em plus 1pt  % space above chapter line
   \@tempdima 1.5em       % width of box holding chapter number
   \begingroup
     \parindent \z@ \rightskip \@pnumwidth
     \parfillskip -\@pnumwidth
     \bfseries                  % Boldface.
     \leavevmode          % TeX command to enter horizontal mode.
    CHAPTER #1\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfill
     \hbox to\@pnumwidth{\hfil #2}\par
   \endgroup}
ucf_436
Posts: 6
Joined: Mon Jun 06, 2011 7:15 pm

Re: Adding Appendix to Table of Contents

Post by ucf_436 »

Removing the chapter in the cls file and replacing it with appendix changed all the sections of the table of contents to appendix. The cls file is written such that it treates the appendix as a chapter. I would need to add an exception so that it recognizes it as not a chapter but an appendix and hence need to add a section in the code I think. But am not sure what exactly the code is. I tried to copy the chapter code and call it appendix instead bu that didn't change anything.

\def\l@chapter#1#2{\pagebreak[3]
\vskip 1.0em plus 1pt % space above chapter line
\@tempdima 1.5em % width of box holding chapter number
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\bfseries % Boldface.
\leavevmode % TeX command to enter horizontal mode.
CHAPTER #1\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfill
\hbox to\@pnumwidth{\hfil #2}\par
\endgroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\l@chapapp#1#2{\pagebreak[3]
\vskip 1.0em plus 1pt % space above chapter line
\@tempdima 1.5em % width of box holding chapter number
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\bfseries % Boldface.
\leavevmode % TeX command to enter horizontal mode.
APPENDIX #1\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfill
\hbox to\@pnumwidth{\hfil #2}\par
\endgroup}


The 2nd section is what I added. Dint help :(
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

Re: Adding Appendix to Table of Contents

Post by west.logan »

No, what I'm saying is that for me, the chapters (in the TOC) are all appearing as "CHAPTER CHAPTER W" or something like that. Then the Appendix appears as "CHAPTER APPENDIX F". If you remove "CHAPTER" from the code specified in the .cls file, then I just get "CHAPTER W" and "APPENDIX F" in the TOC. I did not replace "chapter" with "appendix" or add any code. Is this what you are seeing?
ucf_436
Posts: 6
Joined: Mon Jun 06, 2011 7:15 pm

Re: Adding Appendix to Table of Contents

Post by ucf_436 »

Oh.. I get it now. I dont see that though. The TOC just has chapters for the appendices and the chapter titles. It doesnt have a chapter chapter like yours. If it's the same .cls file I am not sure why there is a difference.
west.logan
Posts: 87
Joined: Tue Sep 14, 2010 6:58 pm

Re: Adding Appendix to Table of Contents

Post by west.logan »

It might be helpful if you just put everything you've got in a zip file. I had to go find and download three or four files to get it to run and it still runs with errors...
ucf_436
Posts: 6
Joined: Mon Jun 06, 2011 7:15 pm

Re: Adding Appendix to Table of Contents

Post by ucf_436 »

I have attached the .clo file as a text file as I wasn't able to attach it with the .clo extension. The initial .tex file I sent had an error so i am attaching it here again. The .clo file also defines the table of contents section and it seems to interfere with the .cls file. Can you rename the attached file to the .clo extension and run our file? Thanks
Attachments
ucfth12.txt
(18.61 KiB) Downloaded 327 times
sample.tex
The sample tex file
(4.91 KiB) Downloaded 327 times
Post Reply