1

In my thesis I have two chapter styles. One is numbered style like - CHAPTER N - INTRODUCTION. For this style I have defined the style in the preamble and write in the main body as

\chapter{INTRODUCTION}

Another one is non numbered style like - APPENDIX. For this style I write

\chapter*{APPENDIX}

The problem in non numbered chpaters are, if I write something under this chpater, it doesn't show in TOC under this chapter. Rather it shows under the previous chapter.

How can I get the contents of non numbered chapter in TOC under the same chapter?

MOI:

\documentclass{report}
\usepackage{lipsum}

\usepackage{titlesec} % chapter and section title formatting
%%Chapter Formatting%%
\titleformat{\chapter}[display]
{\filcenter\fontsize{16}{19.2}\selectfont\rmfamily\bfseries}
{\MakeUppercase{\chaptertitlename}\ \thechapter}
{0pt}
{}
\titlespacing{\chapter}{0pt}{-10pt}{5pt}

\usepackage{titletoc} % Chapter title formatting in ToC
\titlecontents{chapter}[17pt]{\vskip8pt}{\fontsize{14}{16.8}\selectfont\bfseries\MakeUppercase{chapter}~\thecontentslabel\quad}{\bfseries}{\bfseries\hfill\contentspage}[\vskip5pt]

\begin{document}
\tableofcontents
    
\chapter{Intro}
\lipsum[2]
\section{fdsjfhsdf}
\subsection{fdshfkjsf}

\chapter*{Literature Review}
\section{2fkjhsfdk}
\lipsum[4]
\end{document}

2 Answers 2

1

Starred chapters or sections will not appear in the table of contents. They can be added them using

\addcontentsline{table}{level}{title}

Using titletoc you should also define the entries for the section and the subsection.

\titlecontents{type}[left-indent]{above-code}{numbered-entry-format} {numberless-entry-format}{page-format}[below-code]

\documentclass{report}
\usepackage{lipsum}

\usepackage{titlesec} % chapter and section title formatting


%%Chapter Formatting%%
\titleformat{\chapter}[display]
{\filcenter\fontsize{16}{19.2}\selectfont\rmfamily\bfseries}
{\MakeUppercase{\chaptertitlename}\ \thechapter}
{0pt}
{}
\titlespacing{\chapter}{0pt}{-10pt}{5pt}
%

\usepackage{titletoc} % Chapter title formatting in ToC

\titlecontents{chapter} [6pc] %[left-indent]
{\addvspace{1pc}\bfseries}%  {above-code}
{\contentslabel [\textsc{\chaptername}\ \thecontentslabel]{5pc}} %{numbered-entry-format}
{} % {numberless-entry-format}
{\hfill\contentspage} %{page-format}
[\addvspace{2pt}] % [below-code]

\titlecontents{section}[6pc]{\addvspace{2pt}\filright}
{\contentspush{\thecontentslabel\ }}
{}{\titlerule*[8pt]{.}\contentspage}

\titlecontents{subsection}[7.5pc]{\addvspace{2pt}\filright}
{\contentspush{\thecontentslabel\ }}
{}{\titlerule*[8pt]{.}\contentspage}

% Show subsection entries:
\setcounter{tocdepth}{2}

\begin{document}
    \tableofcontents
    
    \chapter{Intro}
    \lipsum[2]
    \section{section one chap. 1}
    \subsection{subsection one chap. 1}
    
    \chapter*{Literature Review}
    \addcontentsline{toc}{chapter}{Literature Review} % added <<<<<<<<<<<<<<
    \section*{section unnumbered chap. 2}
    \addcontentsline{toc}{section}{section unnumbered chap. 2} % added <<<<<<<<<<<<<<
    \lipsum[4]
\end{document}

a

From The LaTeX Companion.– 2nd ed. / Frank Mittelbach and Michel Goossens, with Johannes Braams, David Carlisle, and Chris Rowley. (2004)

\contentslabel[text]{size} The purpose of the \contentslabel command is to typeset the text (which by default contains \thecontentslabel) left aligned in a box of width size and to place that box to the left of the current position. Thus, if you use this command in the numbered-entry-format argument of \titlecontents, then the number will be placed in front of the entry text into the margin or indentation set up by left- indent.

\contentspush{text} This command typesets text and then increases the left-indent by the width of text for all additional lines of the entry (if any). As a consequence, the indentation will vary if the width of the text changes

.

4
  • Thanks for your kind response. It was helpful. But it's not what I'm looking for. I have got an idea from it. Jan 31, 2022 at 18:11
  • @MAzharul Islam Perhaps you can clarify/expand your question. Jan 31, 2022 at 18:16
  • That was my problem, I couldn't express my necessity in the question properly. However I have got an answer to this question. Should I post that as an answer to this question? Jan 31, 2022 at 18:18
  • @MAzharul Islam Of course, if answer your question properly. Jan 31, 2022 at 18:22
0

I have got a solution to the problem. May be I was unable to express the actual problem in the question properly.

Anyways, I've just changed the look of the numbered chapter both in main body and TOC and included every chapter as a new file in the main thesis file

\include{Intro}
\include{literature}

The formatting of the numbered chapter has been defined in the main body. So, every chapters formatting will remain same. However the formatting of the non numbered chapters has been defined in that chapter. so it only affects that particular chapter.

main file

\documentclass{report}
\usepackage{lipsum}

\usepackage{titletoc} % Chapter title formatting in ToC
\titlecontents{chapter}[17pt]{\vskip8pt}{\fontsize{14}{16.8}\selectfont\bfseries\MakeUppercase{chapter}~\thecontentslabel\quad}{\bfseries}{\bfseries\hfill\contentspage}[\vskip5pt]


%%--------------Chapter and Section Formatting------------%%
%%%  Don't use \sectsty package in this document.%%% 

\usepackage{titlesec} % chapter and section title formatting
%%Chapter Formatting%%
\titleformat{\chapter}[display]
{\filcenter\fontsize{16}{19.2}\selectfont\rmfamily\bfseries}
{\MakeUppercase{\chaptertitlename}\ \thechapter}
{0pt}
{}
\titlespacing{\chapter}{0pt}{-10pt}{5pt}

\begin{document}
\tableofcontents
    
\include{Intro}
\include{literature}
\end{document}

regular/numbered chapter: Intro

\chapter{Introduction}
\section{normal section}
\lipsum[2]

non numbered chapter: literature

\titlecontents{chapter}[17pt]{\vskip8pt}{\fontsize{14}{16.8}\selectfont\bfseries}{\bfseries}{\bfseries\hfill\contentspage}[\vskip5pt]

\titleformat{\chapter}[display]
{\filcenter\fontsize{16}{19.2}\normalfont\bfseries}{}{0pt}{\Large}
\titlespacing{\chapter}{0pt}{-29.2pt}{5pt}


\chapter{Literature}
\section{my section}
\lipsum[3]

notice the change in titleformat and titlecontents in the main file and the non numbered chapter.

I know that it doesn't look good to add section counter as 2.1 since the chapter counter is absent. But it can also be changed following this method. TOC Numbered chapter Non numbered chapter

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .