看起来像这样: 这样,页码就位于部分标题的前面,并与其他页码对齐,而部分标题与部分编号对齐。附加:例如,是否可以在 \sc 格式中仅包含“第一部分”?
以下是我从其他答案中得到的代码:
\documentclass{report}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}
\usepackage{titleps}
\usepackage{stackengine}
\usepackage{fmtcount} % For part number in written form
\renewcommand{\thepart}{\Numberstring{part}}
\titleclass{\part}{top}
\titleformat{\part}[display]{\centering\normalfont\large}{\partname>\hspace{4pt}\thepart}{0pt}{\Large}
\titlecontents{part}
[0cm]
{\Large\bfseries\protect\addvspace{15pt}}%
{Part \thecontentslabel\bclap}
{}%
{\enspace\hfill\thecontentspage}%
\begin{document}
\tableofcontents
\part{Title of Part One}
\chapter{chapter}
\section{section}
\part{Title of Part Two}
\chapter{chapter}
\section{section}
\end{document}
答案1
这是一个解决方案。但是要将零件名称改为小写和粗体,您需要一种具有粗体小写字母的字体。我用garamondx
它来做这个。
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage[newparttoc]{titlesec}
\usepackage{garamondx}
\usepackage{titletoc}
\usepackage{titleps}
\usepackage{fmtcount} % For part number in written form
\renewcommand{\thepart}{\Numberstring{part}}
\titleclass{\part}{top}
\titleformat{\part}[display]{\centering\normalfont\large}{\partname>\hspace{4pt}\thepart}{0pt}{\Large}
\titlecontents{part}
[0cm]
{\contentsmargin{0cm}\large\bfseries\protect\addvspace{15pt}}%
{\textsc{Part \thecontentslabel}\newline}
{}%
{\hspace{\fill}\thecontentspage}%
\begin{document}
\tableofcontents
\part{Title of Part One}
\chapter{chapter}
\section{section}
\part{Title of Part Two}
\chapter{chapter}
\section{section}
\end{document}
答案2
像这样?
\documentclass{report}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}
\usepackage{titleps}
\usepackage{stackengine}
\usepackage{fmtcount} % For part number in written form
\renewcommand{\thepart}{\Numberstring{part}}
\titleclass{\part}{top}
\titleformat{\part}[display]{\centering\normalfont\large}{\partname\hspace{4pt}\thepart}{0pt}{\Large}
\titlecontents{part}
[0cm]
{\protect\addvspace{15pt}}%
{\Large\textsc{Part \thecontentslabel}\newline\bfseries}%
{}%
{\Large\bfseries\hfill\thecontentspage\hspace*{-1.2pc}}%
\begin{document}
\tableofcontents
\part{Title of Part One}
\chapter{chapter}
\section{section}
\part{Title of Part Two}
\chapter{chapter}
\section{section}
\end{document}