GeneralTable of Contents - How to show everything? Sections missing

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
ijc
Posts: 25
Joined: Mon Feb 04, 2008 4:26 pm

Table of Contents - How to show everything? Sections missing

Post by ijc »

Hi all,

I am new to LaTeX, and I am trying to write my university dissertation in it...good times.


I'm trying to get my contents page to display all my sections and subsections...at the moment it only displays 4/5 from each chapter but I need it to show all.

I saw the /addtocontents command, but I have many sections and I don't want to have to do that for all of them.


Thanks in advance for your help

IJC

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Table of Contents - How to show everything? Sections missing

Post by gmedina »

Use, in the preamble, something like

Code: Select all

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ijc
Posts: 25
Joined: Mon Feb 04, 2008 4:26 pm

Table of Contents - How to show everything? Sections missing

Post by ijc »

Thanks for you help!

Now all the Chapters, Sections and Sub-Sections appear. :)

Now though, there are not any Sub-Sub-Sections on the contents...

I tried an inventive command \setcounter{subsecnumdepth}{5} but the compiler had no idea what I was talking about :|

IJC
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Table of Contents - How to show everything? Sections missing

Post by gmedina »

The standard sectioning commands and their levels are

Code: Select all

command          |        level 
--------------------------------------
\part            | -1 (book and report) 0 (article)
\chapter         | 0 (book and report only)
\section         | 1
\subsection      | 2
\subsubsection   | 3
\paragraph       | 4
\subparagraph    | 5
So the values that I suggested you to use will work for all these sectioning commands.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ijc
Posts: 25
Joined: Mon Feb 04, 2008 4:26 pm

Table of Contents - How to show everything? Sections missing

Post by ijc »

Sorry how do I use those commands with those levels?


At the moment using

Code: Select all

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
the subsub sections don't appear even though the levels are set to 5 - I think I am misinterpreting it


Thanks for you help, it's much appreciated
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Table of Contents - How to show everything? Sections missing

Post by gmedina »

Adapted from the LaTeX Companion:
The standard LaTeX document classes (book, report, article) provide commands to define the hierarchical structural units of a document (parts, chapters, sections, etc.). Each such command defines a nesting level inside a hierarchy and each structural unit belongs to some level.

Standard LaTeX provides the set of sectioning commands I mentioned in my previous post. The \chapter command defines level zero of the hierarchical structure of a document, \section defines level one, and so on (the optional \part command defines level minus one (in book and report) or zero (in article, since the article class does not have \chapter))
The secnumdepth counter controls the nesting level up to which numbering will be produced. The tocdepth counter controls the nesting level up to which sectional units will be included in the ToC.

The following example shows how every sectioning command down to \subparagraph will be numbered and will appear in the Table of Contents (ToC):

Code: Select all

\documentclass{book} 
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\usepackage{blindtext}

\begin{document} 
\tableofcontents

\chapter{a}
\blindtext
\section{b}
\blindtext
\subsection{c}
\blindtext
\subsubsection{d}
\blindtext
\paragraph{e}
\blindtext
\subparagraph{f}
\blindtext

\end{document}
If the above suggestion causes you problems with \subsubsection, then please post a minimal working example showing the undesired behaviour.

Remark: the blindtext package was loaded only to automatically generate some text.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ijc
Posts: 25
Joined: Mon Feb 04, 2008 4:26 pm

Table of Contents - How to show everything? Sections missing

Post by ijc »

Code: Select all

\documentclass[parskip]{cs4rep}   %cs4rep is a template they want us to conform too

\usepackage[pdftex]{graphicx}
\usepackage{a4wide} 
....
\tableofcontents
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
.....

\chapter{Design}

\section{Specifications}

\section{Major Design Decisions}
\subsection{PicoBlaze}
\subsubsection{PicoBlaze ADC}

\subsection{Fast Fourier Transform}
\subsubsection{Self-coded in Verilog}
\subsubsection{Pre-made Verilog module}
\subsubsection{Xilinx LogiCore}

\subsection{Output Stage}
\subsubsection{On-board LCD}
\subsubsection{VGA Port}
\subsubsection{Data Output Port}

.....

The PDF produced has all the \subsection's (PicoBlaze / Fast Fourier Transform / Output), but none of the \subsubsection's
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Table of Contents - How to show everything? Sections missing

Post by gmedina »

In the cs4rep.cls file i found these definitions:

Code: Select all

%%% Table of contents to list down to subsections and no further
\setcounter{tocdepth}{2}

%%% Number down to subsubsections only
\setcounter{secnumdepth}{3}
So, if you have to use this template, then you should respect these settings. However, if you still want to change them, simply edit the cs4rep.cls file and change the above lines with the values that suit your needs.

Edit: Now that I read more carefully your last post, maybe it is enough to place the \setcounter commands I suggested you in the preamble of your document (before the \begin{document} line).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
ijc
Posts: 25
Joined: Mon Feb 04, 2008 4:26 pm

Re: Table of Contents - How to show everything? Sections missing

Post by ijc »

Excellent! :D


I put the commands above the \begin{document} line and it worked beautifully.

I won't be submitting my report with the larger contents page, but it's going to help me a lot with writing/planning it.

Thanks very much for your help!
Post Reply