我想在目录中的章节号前添加单词“Chapter”(保留代码),如下所示
Table of contents
Chapter 1: Chapter name
并且没有
Table of contents
1 Chapter name
请问如何做?
这是我的代码
\documentclass[a4paper,11pt,x11names]{book}
\usepackage[french]{babel}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\contentsmargin{0cm}
\titlecontents{chapter}
[1.25cm]
{\addvspace{12pt}\large\sffamily\bfseries}
{\color{ocre!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{ocre}}
{\color{ocre}}
{\ \color{ocre!60}\normalsize\titlerule*[.5pc]{.}\;\thecontentspage}
\titlecontents{section}
[2.5cm]
{\addvspace{5pt}\sffamily\bfseries}
{\contentslabel[\thecontentslabel]{1.25cm}}
{}
{\ \normalsize\titlerule*[.5pc]{.}\;\thecontentspage}
\titlecontents{subsection}
[3.75cm]
{\addvspace{1pt}\sffamily\small}
{\contentslabel[\thecontentslabel]{1.25cm}}
{}
{\ \titlerule*[.5pc]{.}\;\thecontentspage}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\section{Section 1}
\subsection{Subsection 1}
\subsubsection{Subsubsection}
\end{document}
答案1
答案2
我没有使用titletoc
包,而是使用tocloft
了包。以下代码提供了您所需的内容。
% chapintocprob.tex SE 623588
\documentclass[a4paper,11pt,x11names]{book}
\usepackage[french]{babel}
\usepackage{titlesec}
%\usepackage{titletoc}
\usepackage{comment}
\usepackage{tocloft}
\renewcommand{\cftchappresnum}{Chapter } % put this before chapter number
\addtolength{\cftchapnumwidth}{4em} % extra space for the above
\renewcommand{\cftchapaftersnum}{:} % put : after chapter number
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % use detted leader
\renewcommand{\cftchapfont}{\bfseries\color{ocre}} % ocre colour for title and dots
\renewcommand{\cftchappagefont}{\bfseries\color{ocre}} % ocre page numbers
\renewcommand{\cftchapafterpnum}{\vspace{\baselineskip}} % extra space below chapter titles
\renewcommand{\cftsecfont}{\bfseries} % bold section titles
\renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftdotsep}} % bold section leader
\renewcommand{\cftsecpagefont}{\bfseries} % bold section page number
\usepackage[T1]{fontenc} % PW suggested by package french.ldf
\usepackage{xcolor}
\definecolor{ocre}{RGB}{243,102,25}
\begin{comment}
\contentsmargin{0cm}
\titlecontents{chapter}
[1.25cm]
{\addvspace{12pt}\large\sffamily\bfseries}
{\color{ocre!60}\contentslabel[\Large\thecontentslabel]{1.25cm}\color{ocre}}
{\color{ocre}}
{\ \color{ocre!60}\normalsize\titlerule*[.5pc]{.}\;\thecontentspage}
\titlecontents{section}
[2.5cm]
{\addvspace{5pt}\sffamily\bfseries}
{\contentslabel[\thecontentslabel]{1.25cm}}
{}
{\ \normalsize\titlerule*[.5pc]{.}\;\thecontentspage}
\titlecontents{subsection}
[3.75cm]
{\addvspace{1pt}\sffamily\small}
{\contentslabel[\thecontentslabel]{1.25cm}}
{}
{\ \titlerule*[.5pc]{.}\;\thecontentspage}
\end{comment}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\section{Section 1}
\subsection{Subsection 1}
\subsubsection{Subsubsection}
\end{document}
tocloft
提供对目录(以及 LoF、LoT)排版所有方面的控制,从分区编号之前,到虚线、页码以及之后。使用起来可能很繁琐,但它可以让您完全控制目录的排版等。