最小工作示例:
\documentclass{report}
\usepackage{titlesec}
\usepackage{titletoc}
\titleclass{\part}{top}
\titleformat{\part}[display]
{\centering\normalfont}
{\itshape \partname~\thepart}{1.0em}
{\bfseries\MakeUppercase}
\titlespacing*{\part}{0pt}{0pt}{20pt}
\renewcommand{\thechapter}{\Roman{chapter}}
\dottedcontents{chapter}[3.0em]{\bfseries}{2.5em}{0pc}
\dottedcontents{section}[4.5em]{}{3.5em}{0.75pc}
\begin{document}
\startcontents[parts]
\part{Part I}
\printcontents[parts]{}{0}{}
\chapter{Chapter I}
\section{Section I.1}
\chapter{Chapter II}
\section{Section II.1}
\chapter{Chapter III}
\section{Section III.1}
\stopcontents[parts]
\end{document}
例如,第 II.1 节的标签应为“1”,而不是“II.1”。
答案1
假设这只是为了在目录中显示,您可以使用的“above-code”参数从\dottedcontents
存储在中的章节编号中删除前导罗马数字,\thecontentslabel
如下所示:
\def\stripleading#1.#2{#2}
\dottedcontents{section}[4.5em]{\xdef\thecontentslabel{\expandafter\stripleading
\thecontentslabel}}{3.5em}{0.75pc}
\documentclass{report}
\usepackage{titlesec}
\usepackage{titletoc}
\titleclass{\part}{top}
\titleformat{\part}[display]
{\centering\normalfont}
{\itshape \partname~\thepart}{1.0em}
{\bfseries\MakeUppercase}
\titlespacing*{\part}{0pt}{0pt}{20pt}
\renewcommand{\thechapter}{\Roman{chapter}}
\dottedcontents{chapter}[3.0em]{\bfseries}{2.5em}{0pc}
\def\stripleading#1.#2{#2}
\dottedcontents{section}[4.5em]{\xdef\thecontentslabel{\expandafter\stripleading\thecontentslabel}}{3.5em}{0.75pc}
\begin{document}
\startcontents[parts]
\part{Part I}
\printcontents[parts]{}{0}{}
\chapter{Chapter I}
\section{Section I.1}
\chapter{Chapter II}
\section{Section II.1}
\section{Section II.2}
\chapter{Chapter III}
\section{Section III.1}
\stopcontents[parts]
\end{document}