LaTeX forum ⇒ Theses, Books, Title pagesAdding 'Chapter 1' instead of '1' to the Contents page

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Corned Beef Hash
Posts: 5
Joined: Thu Oct 15, 2015 5:26 pm

Adding 'Chapter 1' instead of '1' to the Contents page

Postby Corned Beef Hash » Thu Nov 05, 2015 11:20 pm

My University requires that the chapter and appendix names in the table of contents have 'Chapter' and 'Appendix' before each chapter #. I'm lost as to how to accomplish this, I've read the "LaTeX for Complete Novices" chapter referring to this issue, but am having trouble implementing it with the table of contents commands in this template. Is there a way to revise these commands, or would it be best if I just started over and made a new table of contents?

  1. \addtocounter{secnumdepth}{1}
  2. \setcounter{tocdepth}{6}
  3. \newcounter{dummy}
  4. \newcommand\addtotoc[1]{
  5. \refstepcounter{dummy}
  6. \addcontentsline{toc}{chapter}{#1}}
  7. \renewcommand\tableofcontents{
  8. \btypeout{Table of Contents}
  9. \addtotoc{Contents}
  10. \begin{spacing}{1}{
  11. \setlength{\parskip}{1pt}
  12. \if@twocolumn
  13. \@restonecoltrue\onecolumn
  14. \else
  15. \@restonecolfalse
  16. \fi
  17. \chapter*{\contentsname
  18. \@mkboth{
  19. \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}
  20. \@starttoc{toc}
  21. \if@restonecol\twocolumn\fi
  22. \cleardoublepage
  23. }\end{spacing}

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3584
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Nov 05, 2015 11:41 pm

Hi there,

one thing i can tell you is that you are using an obsolete version of the template. It got some huge upgrades and you should be able to switch with just a little bit of effort.

How to have the prefix in the toc? I'll have a loook at that later.
But please, what do you expect to be in a table of contents. I bet you also a requested to have the word figure in your list of figures. What else would you expect there? Socks? Gun powder? Tissues? Sometimes, those university regulations are insane. :-(
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Corned Beef Hash
Posts: 5
Joined: Thu Oct 15, 2015 5:26 pm

Postby Corned Beef Hash » Thu Nov 05, 2015 11:45 pm

Haha, thanks for your condolences! This is the last edit I have to make in the document, so I think I'll stick with this version, unless it would be much easier to switch. I should admit that I am very new to LaTeX, so I might be making some very beginner mistakes. Let me know if there is any other information that I can provide. Thanks for taking a look!

Corned Beef Hash
Posts: 5
Joined: Thu Oct 15, 2015 5:26 pm

Postby Corned Beef Hash » Fri Nov 06, 2015 7:50 am

Posting my own answer. If you use what 'Lockstep' posted at http://tex.stackexchange.com/questions/56839/chaptername-is-used-even-for-appendix-chapters-in-toc, the .cls file can be left as is, and the code that 'Lockstep' wrote:

  1. \usepackage{tocloft,calc}
  2. \renewcommand{\cftchappresnum}{\chaptername\space}
  3. \setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~999~}}}
  4. \makeatletter
  5. \g@addto@macro\appendix{%
  6. \addtocontents{toc}{%
  7. \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
  8. }%
  9. }


Can be pasted into the main.tex file directly before \tableofcontents. The added bonus is that writes in 'Appendix' in addition to 'Chapter'. I know that I am using an older version of the template, so this is probably not applicable to many people, but I thought I'd throw it out there anyway.

Cheers!

User avatar
Stefan Kottwitz
Site Admin
Posts: 8534
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Fri Nov 06, 2015 12:46 pm

Thanks for telling us the solution!

A typical LaTeX hack. :-) A final \makeatother would be cleaner, but is not necessary.

Stefan
Site admin


Return to “Theses, Books, Title pages”

Who is online

Users browsing this forum: No registered users and 1 guest