我将如何创建目录以获得这样的输出......
内容 插图.................................................i 表格.................................................ii 致谢................................................iii 摘要.................................................iv 第1章 简介.................................................1
答案1
如果您想更改\chapter
所有章节的标题,请使用titlesec
包。我不建议您单独更改内容标题。如果您确实想要,您可以添加
\renewcommand*\cfttoctitlefont{\Huge\bfseries\hfill\MakeUppercase}
\renewcommand*\cftaftertoctitle{\hfill}
以下内容将提供或多或少您想要的内容,除了第 1 章之后的换行符。如果您包含章节,那将造成混乱。
\documentclass{book}
\usepackage{tocloft}
\newlength\mylenprt
\newlength\mylenchp
\newlength\mylenapp
\renewcommand*\cftpartpresnum{\partname~}
\renewcommand*\cftchappresnum{\chaptername~}
\renewcommand*\cftchapaftersnum{.}
\renewcommand*\cftchapdotsep{\cftdotsep}
\settowidth\mylenprt{\cftpartfont\cftpartpresnum\cftpartaftersnum}
\settowidth\mylenchp{\cftchapfont\cftchappresnum\cftchapaftersnum}
\settowidth\mylenapp{\cftchapfont\appendixname~\cftchapaftersnum}
\addtolength\mylenprt{\cftpartnumwidth}
\addtolength\mylenchp{\cftchapnumwidth}
\addtolength\mylenapp{\cftchapnumwidth}
\setlength\cftpartnumwidth{\mylenprt}
\setlength\cftchapnumwidth{\mylenchp}
\begin{document}
\frontmatter
\tableofcontents
\chapter{ILLUSTRATIONS}
\makeatletter\@starttoc{lof}\makeatother
\chapter{TABLES}
\makeatletter\@starttoc{lot}\makeatother
\chapter{ACKNOWLEDGEMENT}
\chapter{ABSTRACT}
\mainmatter
\chapter{INTRODUCTION}
\begin{figure}
\caption{Fig test}
\end{figure}
\begin{table}
\caption{Tab Test}
\end{table}
\appendix
\addtocontents{toc}{% NB!!! must be inside the first \include
\protect\renewcommand\protect\cftchappresnum{\appendixname~}%
\protect\setlength{\cftchapnumwidth}{\mylenapp}}%
\backmatter
\end{document}
答案2
这是您问题的重复“目录”。所以这是相同的答案,但添加了命令来打破章节线。添加了命令并重新定义了\cftchapaftersnumb
内部命令。\l@chapter
关于图表标题列表,请记住,它们是章节标题,需要与书中所有其他章节标题的格式相同。如果您想要其他内容,请查看我在帖子中的回答“如何在同一页和目录中显示 \listoffigures 和 \listoftables?”。您可以对其进行调整,使它们成为章节标题。
\documentclass{book}
\usepackage{tocloft}
\newlength\mylenprt
\newlength\mylenchp
\newlength\mylenapp
\renewcommand*\cftpartpresnum{\partname~}
\renewcommand*\cftchappresnum{\chaptername~}
\renewcommand*\cftchapaftersnum{.}
\renewcommand*\cftchapaftersnumb{\par\smallskip} %<<<<<<<< ADDED <<<<<
\renewcommand*\cftchapdotsep{\cftdotsep}
\settowidth\mylenprt{\cftpartfont\cftpartpresnum\cftpartaftersnum}
\settowidth\mylenchp{\cftchapfont\cftchappresnum\cftchapaftersnum}
\settowidth\mylenapp{\cftchapfont\appendixname~\cftchapaftersnum}
\addtolength\mylenprt{\cftpartnumwidth}
\addtolength\mylenchp{\cftchapnumwidth}
\addtolength\mylenapp{\cftchapnumwidth}
\setlength\cftpartnumwidth{\mylenprt}
\setlength\cftchapnumwidth{\mylenchp}
\makeatletter
\renewcommand*{\l@chapter}[2]{%
\ifnum \c@tocdepth >\m@ne
\addpenalty{-\@highpenalty}%
\vskip \cftbeforechapskip
{\leftskip \cftchapindent\relax
\rightskip \@tocrmarg
\parfillskip -\rightskip
\parindent \cftchapindent\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima \cftchapnumwidth\relax
\let\@cftbsnum \cftchappresnum
\let\@cftasnum \cftchapaftersnum
\let\@cftasnumb \cftchapaftersnumb
%\advance\leftskip \@tempdima %<<<<<< CHANGE <<<<<
\null\nobreak\hskip -\leftskip
{\cftchapfont #1}\nobreak
\cftchapfillnum{#2}}%
\fi}%
\makeatother
\begin{document}
\frontmatter
\tableofcontents
\chapter{ILLUSTRATIONS}
\makeatletter\@starttoc{lof}\makeatother
\chapter{TABLES}
\makeatletter\@starttoc{lot}\makeatother
\chapter{ACKNOWLEDGEMENT}
\chapter{ABSTRACT}
\mainmatter
\chapter{INTRODUCTION}
\section{MySQL}
\section{Java}
\mainmatter
\chapter{THEORETICAL CONSIDERATIONS}
\section{Records Management}
\subsection{Entity-relationship diagram}
\begin{figure}
\caption{Fig test}
\end{figure}
\begin{table}
\caption{Tab Test}
\end{table}
\appendix
\addtocontents{toc}{% NB!!! must be inside the first \include
\protect\renewcommand\protect\cftchappresnum{\appendixname~}%
\protect\setlength{\cftchapnumwidth}{\mylenapp}}%
\backmatter
\end{document}