我正在尝试修改我的目录,这是我的代码的一部分
\renewcommand{\contentsname }{ TABLE OF CONTENTS}
\tableofcontents
\addtocontents{toc}{~\hfill Page\par}
\let\LaTeXStandardTableOfContents\tableofcontents
\renewcommand{\tableofcontents}{%
\begingroup%
\renewcommand{\bfseries}{\relax}%
\LaTeXStandardTableOfContents%
\endgroup%
}%
输出为
我想要的是
有两个不同之处。
1)目录未加粗。
2)“INTRODUCTION”上方没有出现“CHAPTER 1”一词
我该如何修复这些问题?
答案1
这是一个解决方案titletoc
:
\documentclass[11pt, english]{book}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{fourier, erewhon, cabin}
\usepackage[showframe]{geometry}
\usepackage[clearempty, pagestyles]{titlesec}
\usepackage{titletoc}
\usepackage{lipsum}
\titleformat{\chapter}[display]%
{\null\vskip1em\sffamily\bfseries\Large\filleft}{Chapter \thechapter}{2ex}{\LARGE}
\titleformat{name = \chapter, numberless}[block]%
{\null\vskip1em\sffamily\bfseries\Large\filleft}{}{0em}{\LARGE}
\titlespacing*{\chapter}{0em}{-2\baselineskip}{4\baselineskip}
\addto\captionsenglish{\renewcommand*\contentsname{Table of Contents}}
\titlecontents{chapter}
[0em] %
{\medskip}
{\contentslabel[\rlap{\MakeUppercase\chaptername~\thecontentslabel}]{0em}\endgraf\MakeUppercase}% for numbered chapters
{\MakeUppercase} % for unnumbered chapters
{\hfill\contentspage}[\smallskip]
\titlecontents{section}
[3em]%
{\medskip}
{\thecontentslabel\enspace}% for numbered sections
{\hspace*{1.82em}} for unnumbered sections
{\hfill\contentspage}%]
\begin{document}
\frontmatter
\tableofcontents
\listoffigures \addcontentsline{toc}{chapter}{\listfigurename}
\listoftables \addcontentsline{toc}{chapter}{\listtablename}
\mainmatter
\chapter{Introduction}
\lipsum[1]
\section{Clinical Trials}
\lipsum[2-5]
\section*{A test section}\addcontentsline{toc}{section}{A test section}
\lipsum[6-10]
\chapter{Chapter Two}
Content
\end{document}