答案1
既然你不想,我会为你发布一个 MWE 来开始工作(編輯根据 OP 的愿望):
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{tocloft} % to center the part name
\renewcommand\cftpartpresnum{\hfill}
\renewcommand\cftpartleader{\hfill}
\begin{document}
\tableofcontents
\part{A Title}
\addtocontents{toc}{\nobreak\smallskip\hrule}
\section{Foo bar}
Some text.
\end{document}
添加
从您的问题中无法清楚看出您是只希望在特定部分标题下设置规则,还是希望在所有部分标题下设置规则。在第二种情况下,阅读软件包的文档后tocloft
,我认为可以采用一种更简单的解决方案:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{tocloft} % to center the part name
\renewcommand*{\cftpartpresnum} {\hfill}
\renewcommand*{\cftpartleader} {\hfill}
\renewcommand*{\cftpartafterpnum}{\par\nobreak\smallskip\hrule}
\begin{document}
\tableofcontents
\part{A Title}
\section{Foo bar}
Some text.
\section{Biz baz}
Some text.
\part{Another Title}
\section{Yuk yuk}\
Some text.
\section{Hu-hu?}
Some text.
\end{document}