1

I am using the article class and I am using the \title command to create titles for each chapter. I could use \chapter with the book class, but I prefer to use article class.

So, for instance, for the introduction I would write:

\title{\underline{\textbf{Chapter 1}} \bigskip \bigskip \break 
\textbf{Introduction}}
  \date{}
\maketitle

For sections and subsections I use the usual \section and \subsection commands.

Given this, how can I include titles in the table of contents?

Right now I make the table of contents appear using:

\renewcommand*\contentsname{Table of contents}
\tableofcontents
\newpage

This produces a table of contents ignoring chapters.

I want it to look as follows:

Table of contents (title of page)

    Acknowledgements.......................i
    Table of contents....................iii
    List of tables.......................vii  
    List of figures......................vii  
    Chapter 1. Introduction................1  
       1.1. Section Title..................4
       1.2. Section Title.................14
       1.3. Section Title.................24
           1.3.1. Subsection title........26
           1.3.2. Subsection title........29
    Chapter 2. Chapter 2 Title here.......40

I tried to use \addcontentsline{toc}{chapter} but unsuccessfully

Note that as it stands the Acknowledgements title is also created with \title and the corresponding section appears before the table of contents.

3
  • 3
    Maybe the report class is a good middle option between article and book? report has \chapter but it has less whitespace compared to book. Using a section level with a class that does not have this level (i.e., what you try to do) is bound to result in several problems.
    – Marijn
    Commented Jul 30, 2021 at 16:09
  • 1
    Why do you prefer the article class in preference to book? You might try the memoir class which enables you to sort of swap between book and article appearance. Commented Jul 30, 2021 at 16:57
  • How are you planning on getting the \section etc., numbers preceeded by the "chapter" numbers? Commented Jul 30, 2021 at 17:06

1 Answer 1

0

This is a wrong approach. Give to Caesar what belongs to Caesar and to \title what belongs to \title (that is, the title of the document and nothig else).

What you show is the ToC of a book, not of an article, with chapters, and a front matter with roman numerals, etc. Force to the article class to behave like a book is against nature.

A better approach is to use the memoir class and simply add the option article to format the chapters like the sections, without having to do anything else. Moreover, this class is very customizable, so you can change the ToC exactly as you showed without the help of extra packages. Example:

mwe

\documentclass[article,oneside,12pt]{memoir}
\usepackage{lipsum}
\setsecnumdepth{subsubsection}
\settocdepth{subsubsection}
\renewcommand{\contentsname}{Table of contents} 
\renewcommand*{\cftchapterdotsep}{\cftdotsep}
\renewcommand*{\cftchaptername}{Chapter\space}
\renewcommand{\cftchapteraftersnum}{.}
\begin{document}
\frontmatter
\tableofcontents* % * = No sense show the ToC in the ToC ...
\clearpage
\listoftables\clearpage
\listoffigures\clearpage
\mainmatter
\chapter{foo}\lipsum[1-10]
\section{abc}\lipsum[11-20]
\section{def}\lipsum[21-30]
\begin{table}\caption{table}\end{table}\newpage
\begin{figure}\caption{figure}\end{figure}\newpage
\subsection{ghi}\lipsum[31-39]
\subsection{jkl}\lipsum[40-49]
\subsubsection{mno}\lipsum[50-52]
\subsubsection{pqr}\lipsum[54]
\chapter{bah}\lipsum[55]
\end{document}
1
  • thanks! I was trying now report has someone suggested in the comments and that is also working well it seems. But I will also try this one and compare the outputs. thanks! Commented Jul 31, 2021 at 10:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .
https://tex.stackexchange.com/questions/609041/includes-titles-in-table-of-contents
tex.stackexchange.com
CC-MAIN-2024-26
147142
application/http; msgtype=response
sha1:6LKDDLLMVFBBSCRIAZJYOAPG7XW6E5J7
<urn:uuid:1dfd2737-04d3-464b-9d32-98676e9703ad>
2024-06-22T01:16:47Z
104.18.43.226
text/html
sha1:AN4QOCVLE5UBBLJBKNWCWSF3IMXQHEOT
<urn:uuid:5998324f-3e5f-4e81-99f4-35c35ea1e34e>
https://tex.stackexchange.com/questions/609041/includes-titles-in-table-of-contents
response
<urn:uuid:709c1791-421c-44f7-9586-256fa5870032>
isPartOf: CC-MAIN-2024-26
publisher: Common Crawl
description: Wide crawl of the web for June 2024
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-21
software: Apache Nutch 1.20 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.5-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/