如果我希望 LaTeX 给出“第 1 章:”等,而不是像通常那样只给出数字“1”等,我该怎么做?我希望它以大写字母写出单词“CHAPTER”,然后是章节编号,然后是“:”冒号,最后是大写的“CHAPTER TITLE”。请您帮忙。它应该看起来像这样:
第 1 章:第一章
1.1 第一节
1.1.1 第一小节
答案1
像这样?我titlesec
用过titletoc
:
\documentclass[12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{fourier, erewhon, cabin}
\usepackage[english]{babel}
\usepackage{geometry}
\usepackage[clearempty]{titlesec}
\usepackage{titletoc}
\usepackage{lipsum} \addto\captionsenglish{ \renewcommand*\contentsname{\centerline{Table of contents}}}
\titleformat{\chapter}[display]%
{\null\vskip1em\sffamily\bfseries\Large\filcenter}{Chapter \thechapter}{2ex}{\LARGE}[]
\titleformat{name = \chapter, numberless}[block]%
{\null\vskip1em\sffamily\bfseries\Large\filcenter}{}{0em}{\LARGE}
\titlespacing*{\chapter}{0em}{-2\baselineskip}{6\baselineskip}
\titlecontents{chapter}
[7em] % ie, width of contentslabel + 0.5em
{\bigskip}
{\contentslabel[\MakeUppercase\chaptername~\thecontentslabel]{6.5em}\MakeUppercase}%\thecontentslabel
{\hspace*{-6.5em}\MakeUppercase}
{\hfill\contentspage}[\medskip]
\begin{document}
\tableofcontents
\newpage
\chapter*{An Unnumbered Chapter}
\addcontentsline{toc}{chapter}{An Unnumbered Chapter}
\chapter{Chapter One}
\lipsum[1]
\section{A first nice section}
\lipsum[2-5]
\subsection{A first subsection}
\lipsum[6]
\chapter{Chapter Two}
Content
\end{document}
或者也许是以下代码:
\titlecontents{chapter}
[6.5em] %
{\bigskip}
{\contentslabel[\MakeUppercase\chaptername~\thecontentslabel]{6.5em}\MakeUppercase}%\thecontentslabel
{\hspace*{-6.5em}\MakeUppercase}
{\hfill\contentspage}[\smallskip]
\titlecontents{section}
[0em] % i
{\medskip}
{\thecontentslabel\enspace}%\thecontentslabel
{\hspace*{-6.5em}}
{\hfill\contentspage}%]
\titlecontents{subsection}
[0em] %
{\smallskip}
{\thecontentslabel\enspace}%\thecontentslabel
{\hspace*{-6.5em}}
{\hfill\contentspage}