对于目录中的多行章节名称,如何让第二行和第三行与第一行第一个单词的第一个字母对齐?目前,第二行和第三行从我需要的位置的左侧开始。
\documentclass[12pt,a4paper]{report}
\def\chapter{\newpage\thispagestyle{plain}\secdef\CHAPa\CHAPb}
\def\CHAPa[#1]#2{%
\refstepcounter{chapter}
\addtocontents{toc}{\protect\addvspace{10\p@}}
\addtocontents{lof}{\protect\addvspace{15pt}}
\addtocontents{lot}{\protect\addvspace{15pt}}
\addcontentsline{toc}{chapter}%
{\chaptername{\protect\ \thechapter: #1}}%
% \addcontentsline{toc}{chapter}%
% {\protect\numberline{\chaptername {\thechapter}:}#1}%
\renewcommand{\KM}{#2}
{{\centering \chaptername\ \thechapter \par}
{ \centering #2\par}}
\vspace{\baselineskip}}
\def\CHAPb#1{%
{ \centering #1\par}
\vspace{\baselineskip}}
\newcommand{\KM}{Introduction}
\newcommand{\sectionThesis}[1]{\renewcommand{\KM}{\sf #1}\section{#1}}
\titlecontents{chapter}
[0pt]
{}%
{\contentsmargin{0pt}
\thecontentslabel\enspace%
}
{\contentsmargin{0pt}}
{\titlerule*[.5pc]{.}\contentspage}
\begin{document}
\tableofcontents
\chapter{APPLICATION OF DISCRETE IT\^O FORMULAE TO A NONLINEAR STOCHASTIC DIFFERENCE EQUATION}
\end{document}
答案1
您可以使用tocloft
来代替titletoc
以获得更好的结果。
相关代码是
\usepackage[titles]{tocloft}
\newlength\mylength
\renewcommand\cftchapleader{\cftdotfill{\cftdotsep}}
\renewcommand\cftchapfont{\normalfont}
\renewcommand\cftchappagefont{\normalfont}
\renewcommand\cftchappresnum{\chaptername~}
\renewcommand\cftchapaftersnum{:}
\settowidth\mylength{\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}
完整代码(我也稍微改变了你的定义\CHAPa
):
\documentclass[12pt,a4paper]{report}
\usepackage[titles]{tocloft}
\newlength\mylength
\renewcommand\cftchapleader{\cftdotfill{\cftdotsep}}
\renewcommand\cftchapfont{\normalfont}
\renewcommand\cftchappagefont{\normalfont}
\renewcommand\cftchappresnum{\chaptername~}
\renewcommand\cftchapaftersnum{:}
\settowidth\mylength{\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}
\def\chapter{\newpage\thispagestyle{plain}\secdef\CHAPa\CHAPb}
\def\CHAPa[#1]#2{%
\refstepcounter{chapter}
\addtocontents{toc}{\protect\addvspace{10pt}}
\addtocontents{lof}{\protect\addvspace{15pt}}
\addtocontents{lot}{\protect\addvspace{15pt}}
\addcontentsline{toc}{chapter}%
{\protect\numberline{\thechapter}#1}%
\renewcommand{\KM}{#2}
{{\centering \chaptername\ \thechapter \par}
{ \centering #2\par}}
\vspace{\baselineskip}}
\def\CHAPb#1{%
{ \centering #1\par}
\vspace{\baselineskip}}
\newcommand{\KM}{Introduction}
\newcommand{\sectionThesis}[1]{\renewcommand{\KM}{\sffamily #1}\section{#1}}
\begin{document}
\tableofcontents
\chapter{APPLICATION OF DISCRETE IT\^O FORMULAE TO A NONLINEAR STOCHASTIC DIFFERENCE EQUATION}
\end{document}
titletoc
使用以下设置可以获得类似的结果:
\titlecontents{chapter}
[5.5em]
{}%
{\contentslabel{5.5em}}
{\hspace*{-5.5em}}
{\titlerule*[.5pc]{.}\contentspage}
但结果不太好:
完整代码:
\documentclass[12pt,a4paper]{report}
\usepackage{titletoc}
\def\chapter{\newpage\thispagestyle{plain}\secdef\CHAPa\CHAPb}
\def\CHAPa[#1]#2{%
\refstepcounter{chapter}
\addtocontents{toc}{\protect\addvspace{10pt}}
\addtocontents{lof}{\protect\addvspace{15pt}}
\addtocontents{lot}{\protect\addvspace{15pt}}
% \addcontentsline{toc}{chapter}%
% {{\chaptername\ \thechapter: }#1}%
\addcontentsline{toc}{chapter}%
{\protect\numberline{\chaptername\ \thechapter: }#1}%
\renewcommand{\KM}{#2}
{{\centering \chaptername\ \thechapter \par}
{ \centering #2\par}}
\vspace{\baselineskip}}
\def\CHAPb#1{%
{ \centering #1\par}
\vspace{\baselineskip}}
\newcommand{\KM}{Introduction}
\newcommand{\sectionThesis}[1]{\renewcommand{\KM}{\sffamily #1}\section{#1}}
\titlecontents{chapter}
[5.5em]
{}%
{\contentslabel{5.5em}}
{\hspace*{-5.5em}}
{\titlerule*[.5pc]{.}\contentspage}
\begin{document}
\tableofcontents
\chapter{APPLICATION OF DISCRETE IT\^O FORMULAE TO A NONLINEAR STOCHASTIC DIFFERENCE EQUATION}
\end{document}