Titletoc 页边距和部分内容名称

Titletoc 页边距和部分内容名称

titlesec我正在使用和制作论文的目录titletoc。我终于弄清楚了如何设置章节条目的边距以与部分对齐,但冒号和章节名称之间的空间看起来不够宽。我可以在不弄乱左侧对齐的情况下在第十章:和名称之间留出更多空间吗?

另外,如何才能在该部分的罗马数字后面加上冒号,即第一部分:文本。

谢谢!

\documentclass[12pt]{report} %12 pt font

\usepackage[letterpaper,margin=1in]{geometry} %paper size and margins

\usepackage{titletoc}
\titlecontents{part}[0in]{\vspace{\baselineskip}}%left margin and above code
{}%numbered parts
{\Large\bfseries PART \MakeUppercase}%numberless parts which is all of them?%
{}%no page number

\titlecontents{chapter}[1in]{}%left margin and above code
{\contentslabel[\MakeUppercase{\chaptername}~\thecontentslabel:~]{1in}\MakeUppercase}%numbered chapters
{\hspace*{-1in}\MakeUppercase}%numberless chapters%
{\titlerule*[.5pc]{.}\contentspage}%fill with dots

\usepackage{titlesec}
\titleformat{\chapter}{\bfseries\centering}{CHAPTER \thechapter: }{0em}{\MakeUppercase}
\titleformat{\section}{\bfseries}{\thesection }{0em}{}
\titlespacing{\chapter}{0em}{0em}{\parskip} %reduce vertical spacing before and after chapter headings

\setcounter{tocdepth}{1} %show sections in TOC

\begin{document}
    \tableofcontents

    \part{Text}
    
    \chapter{A Numbered Chapter}
    \chapter*{An unnumbered chapter}
    \addcontentsline{toc}{chapter}{An unnumbered chapter}
    
    \part{Scores}

    \chapter*{An unnumbered chapter}
    \addcontentsline{toc}{chapter}{An unnumbered chapter}
    \addcontentsline{toc}{chapter}{These will be PDFs}
    \section*{This is a section}
    \addcontentsline{toc}{section}{This is a section}
\end{document}```

答案1

您必须titlesec使用选项加载[newparttoc]并重新定义 \part 的格式,以及使用 重新定义目录中各部分的格式\titlecontents。这是一个解决方案。对于 的格式\part,我尝试获取与报告类中的默认布局尽可能接近的布局。

\documentclass[12pt]{report} %12 pt font
\usepackage{xcolor}
\usepackage[letterpaper,margin=1in]{geometry} %paper size and margins

\usepackage{titletoc}
\titlecontents{part}[0in]{\vspace{\baselineskip}}%left margin and above code
{\Large\bfseries PART \MakeUppercase\thecontentslabel{:} }%numbered parts
{\Large\bfseries PART \MakeUppercase}%numberless parts which is all of them?%
{}%no page number

\titlecontents{chapter}[1.1in]{}%left margin and above code
{\contentslabel[\MakeUppercase{\chaptername}~\thecontentslabel: ]{1.1in}\MakeUppercase}%numbered chapters
{\hspace*{-1.1in}\MakeUppercase}%numberless chapters%
{\titlerule*[.5pc]{.}\contentspage}%fill with dots

\usepackage[newparttoc]{titlesec}

\titleformat{\part}[display]{\huge\bfseries\filcenter}{\partname\,\Roman{part}}{2ex}{}[\clearpage]
\titlespacing{\part}{0ex}{*36}{*10}
\titleformat{\chapter}{\bfseries\centering}{CHAPTER \thechapter: }{0em}{\MakeUppercase}
\titleformat{\section}{\bfseries}{\thesection }{0em}{}
\titlespacing{\chapter}{0em}{0em}{\parskip} %reduce vertical spacing before and after chapter headings

\setcounter{tocdepth}{1} %show sections in TOC

\begin{document}

    \tableofcontents

    \part{Text}

    \chapter{A Numbered Chapter}
    \chapter*{An unnumbered chapter}
    \addcontentsline{toc}{chapter}{An unnumbered chapter}

    \part{Scores}

    \chapter*{An unnumbered chapter}
    \addcontentsline{toc}{chapter}{An unnumbered chapter}
    \addcontentsline{toc}{chapter}{These will be PDFs}
    \section*{This is a section}
    \addcontentsline{toc}{section}{This is a section}

\end{document} 

在此处输入图片描述

相关内容