如何在书籍文档类的目录中包含小节?

如何在书籍文档类的目录中包含小节?

我想在目录中包含子部分。

梅威瑟:

\documentclass[lang=en,11pt]{elegantbook}
\usepackage{mathbang} % to write bengali digits in math mode
%--------------------------------------------------
%Bengali Font in Document
%--------------------------------------------------

%\usepackage[banglamainfont=Kalpurush, banglattfont=Siyam Rupali, feature=0, changecounternumbering=0]{latexbangla} % to write bengali in latex
%.................................................................................


\usepackage{xcolor} % Required for specifying colors by name
\definecolor{ocre}{RGB}{243,102,25} % Define the orange color used for highlighting



%----------------------------------------------------------------------------------------
%   BIBLIOGRAPHY AND INDEX
%----------------------------------------------------------------------------------------

%\usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]{biblatex}
%\addbibresource{bibliography.bib} % BibTeX bibliography file
%\defbibheading{bibempty}{}

\usepackage{calc} % For simpler calculation - used for spacing the index letter headings correctly

\usepackage{makeidx} % Required to make an index
\makeindex % Tells LaTeX to create the files required for indexing


%create an .ist style file named as myheader.ist and tell makeindex to use it. My style file is as follows:
%headings_flag 1
%heading_prefix "{\\textbf{"
%heading_suffix "}}\\nopagebreak\n"

%Running the following commands to make index:
%pdflatex myfile.tex
%makeindex -s myheader.ist elegantbook-en.idx
%pdflatex myfile.tex

%----------------------------------------------------------------------------------------
%   MAIN TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\usepackage{titletoc} % Required for manipulating the table of contents

\contentsmargin{0cm} % Removes the default margin

% Part text styling (this is mostly taken care of in the PART HEADINGS section of this file)
\titlecontents{part}
    [0cm] % Left indentation
    {\addvspace{20pt}\bfseries} % Spacing and font options for parts
    {}
    {}
    {}

% Chapter text styling
\titlecontents{chapter}
    [1cm] % Left indentation
    {\addvspace{12pt}\large\sffamily\bfseries} % Spacing and font options for chapters
    {\color{blue!80!ocre}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{blue!80!ocre}} % Formatting of numbered sections of this type
    {\color{blue!80!ocre}} % Formatting of numberless sections of this type
    {\color{blue!80!ocre}\normalsize\;\titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number

% Section text styling
\titlecontents{section}
    [2cm] % Left indentation
    {\addvspace{3pt}\sffamily\bfseries} % Spacing and font options for sections
    {\color{blue!60!red}\contentslabel[\Large\thecontentslabel]{1.50cm}\color{blue!60!red}} % Formatting of numbered sections of this type
    {\color{blue!60!red}} % Formatting of numberless sections of this type
    {\color{blue!60!red}\normalsize\;\titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number

% Subsection text styling
\titlecontents{subsection}
    [3cm] % Left indentation
{\addvspace{1pt}\sffamily\bfseries} % Spacing and font options for sections
    {\color{blue!40!orange}\contentslabel[\Large\thecontentslabel]{2cm}\color{blue!40!orange}} % Formatting of numbered sections of this type
    {\color{blue!40!orange}} % Formatting of numberless sections of this type
    {\color{blue!40!orange}\normalsize\; \titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number



% Figure text styling
\titlecontents{figure}
    [1.25cm] % Left indentation
    {\addvspace{1pt}\sffamily\small} % Spacing and font options for figures
    {\thecontentslabel\hspace*{1em}} % Formatting of numbered sections of this type
    {} % Formatting of numberless sections of this type
    {\ \titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number

% Table text styling
\titlecontents{table}
    [1.25cm] % Left indentation
    {\addvspace{1pt}\sffamily\small} % Spacing and font options for tables
    {\thecontentslabel\hspace*{1em}} % Formatting of numbered sections of this type
    {} % Formatting of numberless sections of this type
    {\ \titlerule*[.5pc]{.}\;\thecontentspage} % Formatting of the filler to the right of the heading and the page number

%----------------------------------------------------------------------------------------
%   MINI TABLE OF CONTENTS IN PART HEADS
%----------------------------------------------------------------------------------------

% Chapter text styling
\titlecontents{lchapter}
    [0em] % Left indentation
    {\addvspace{15pt}\large\sffamily\bfseries} % Spacing and font options for chapters
    {\color{ocre}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{ocre}} % Chapter number
    {}  
    {\color{ocre}\normalsize\sffamily\bfseries\;\titlerule*[.5pc]{.}\;\thecontentspage} % Page number

% Section text styling
\titlecontents{lsection}
    [0em] % Left indentation
    {\sffamily\small} % Spacing and font options for sections
    {\contentslabel[\thecontentslabel]{1.25cm}} % Section number
    {}
    {}

% Subsection text styling (note these aren't shown by default, display them by searchings this file for tocdepth and reading the commented text)
\titlecontents{lsubsection}
    [.5em] % Left indentation
    {\sffamily\footnotesize} % Spacing and font options for subsections
    {\contentslabel[\thecontentslabel]{1.25cm}}
    {}
    {}

%--------------------------------------------------
%Header Ornamenty
%--------------------------------------------------
\fancyhead[R]{\color{structurecolor}\thepage}
\usepackage{fourier-orns}
\renewcommand\headrule{\hrulefill
    \raisebox{-2.1pt}[10pt][10pt]{\color{structurecolor}\quad\decofourleft\decoone\decofourright\quad}\hrulefill}

%.................................................................................


\title{This is  Sample Title}
\subtitle{Classic Book}

\author{Author's Name}
\institute{Author's  Institution}
\date{\today}
\version{3.10}
\bioinfo{Bio}{Information}

\extrainfo{Victory won\rq t come to us unless we go to it. }

\logo{logo-blue.png}
\cover{cover.jpg}

\begin{document}

\maketitle

\frontmatter
\tableofcontents

\mainmatter
\chapter{This is first Chapter}
Chapter contents here.

\newpage 
\section{First section}
Section  contents here.

\newpage 
\subsection{First section}
Subsection  contents here.


Some text.\index{Apple}\index{Apricot}\index{Avocado}\index{Banana}
\index{Bilberry}\index{Blackberry}\index{Blackcurrant}\index{Blueberry}


\newpage 
\subsubsection{First section}
Subsection  contents here


%\printbibliography[heading=bibempty,type=book]

%----------------------------------------------------------------------------------------
%   INDEX
%----------------------------------------------------------------------------------------

\cleardoublepage % Make sure the index starts on an odd (right side) page
\phantomsection
\setlength{\columnsep}{0.75cm} % Space between the 2 columns of the index
\addcontentsline{toc}{chapter}{\textcolor{ocre}{Index}} % Add an Index heading to the table of contents
\printindex % Output the index

%----------------------------------------------------------------------------------------


\end{document}

输出:
在此处输入图片描述

答案1

目录中显示的内容由计数器控制tocdepth。如果为 0,则显示章节及以上内容,如果为 1,则显示章节及以上内容,依此类推。若要获取目录中的子章节,则

\setcounter{tocdepth}{2}

在你的序言中。

如果你正在使用memoir类(的超集bookreportarticle),那么它提供了一个宏\settocdepth{<secname>},其中子部分

\maxtocdepth{subparagraph} % to allow all entries
\settocdepth{subsection}   % to limit entries to subsections

在序言中。

相关内容