目录中的中心部分标题

目录中的中心部分标题

我想将部分标题放在论文的目录 (TOC) 中居中。根据 egreg 的回答,我至少能够修改目录中部分编号和部分标题之间的间距。
但是,我无法为每个 \part 单独设置此长度(我在下面的 MWE 中尝试过,但从结果中可以看出,它不起作用)。

\documentclass[dottedtoc]{scrreprt}
\usepackage[parts]{classicthesis} 
%custom space between number and text in toc: https://tex.stackexchange.com/a/140053/38853
\makeatletter
\def\ttl@tocpart{% %magic code, don't ask
  \def\ttl@a{\protect\numberline{\thepart}\@gobble{}}}
\setlength{\cftpartnumwidth}{100px}
\makeatother

\begin{document}
\tableofcontents 
\part{P1}
\chapter{Ch1}
\setlength{\cftpartnumwidth}{150px}
\part{P2}
\chapter{Ch2}
\end{document}

结果: 在此处输入图片描述

也欢迎其他解决方案!
(我知道https://tex.stackexchange.com/a/210676/38853但是,我不知道如何将零件号放在左边,将页码放在右边,如图所示)

答案1

根据 Johannes_B 的评论,我的 hacky 解决方案可以完成:

\documentclass[dottedtoc]{scrreprt}
\usepackage[parts]{classicthesis} 
%custom space between number and text in toc: http://tex.stackexchange.com/a/140053/38853
\makeatletter
\def\ttl@tocpart{% %magic code, don't ask
  \def\ttl@a{\protect\numberline{\thepart}\@gobble{}}}
\setlength{\cftpartnumwidth}{100px}
\makeatother

\begin{document}
\tableofcontents 
\part{P1}
\chapter{Ch1}
\addtocontents{toc}{\protect\setlength{\cftpartnumwidth}{150px}}
\part{P2}
\chapter{Ch2}
\end{document}

产量

在此处输入图片描述

尽管如此,我们仍然欢迎提供更舒适的标题居中解决方案。:)

相关内容