![目录中的部分内容分为两行](https://linux22.com/image/338097/%E7%9B%AE%E5%BD%95%E4%B8%AD%E7%9A%84%E9%83%A8%E5%88%86%E5%86%85%E5%AE%B9%E5%88%86%E4%B8%BA%E4%B8%A4%E8%A1%8C.png)
看起来像这样:
这样,页码就位于部分标题的前面,并与其他页码对齐,而部分标题与部分编号对齐。附加:例如,是否可以在 \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}