我尝试将目录中的章节号更改为第 I、II、III 章,并且完成了。
\documentclass{report}
\usepackage{tocloft}
\addtocontents{toc}{~\hfill{\small Page}\par}
\AtBeginDocument{% \renewcommand\contentsname{CONTENTS} }
% Centered title for ToC
\renewcommand{\cfttoctitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill}
% Leaders for chapter entries
\renewcommand\cftchapdotsep{\cftdotsep}
% Add space to account for new chapter numbering schema
\renewcommand\cftchapnumwidth{8em}
\renewcommand\cftsecindent{3em}
% Redefine representation for chapter (and section) counters
\renewcommand\thechapter{CHAPTER \Roman{chapter}}
\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\begin{document}
\pagenumbering{roman}
\setcounter{page}{7}
\tableofcontents
\clearpage
\pagenumbering{arabic}
\chapter{INTRODUCTION}
\section{Background}
\section{Objectives}
\chapter{REVIEW}
\section{Test Section}
\section{AnotherTest Section}
\chapter{CODE}
\chapter{END}
\chapter*{APPENDIX}
\addcontentsline{toc}{chapter}{APPENDIX}
\end{document}
但对于主要内容,我想创建这样的输出
请帮帮我。
答案1
我建议不要在更新时\thechapter
包含前缀 一词CHAPTER
。相反,将其添加到\cftchappresnum
。也就是说,使用类似以下内容的内容:
\renewcommand\cftchappresnum{CHAPTER }
\renewcommand\thechapter{\Roman{chapter}}
然后,要使章节标题居中,您可以使用titlesec
:
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\centering}{CHAPTER \thechapter}{20pt}{\Huge}
这是一个涵盖所有内容的最小示例:
\documentclass{report}
\usepackage{tocloft}
\addtocontents{toc}{~\hfill{\small Page}\par}
\renewcommand\contentsname{CONTENTS}
%\renewcommand{\chaptername}{}
% Centered title for ToC
\renewcommand{\cfttoctitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill\null}
% Leaders for chapter entries
\renewcommand\cftchapdotsep{\cftdotsep}
% Add space to account for new chapter numbering schema
\renewcommand\cftchapnumwidth{8em}
\renewcommand\cftsecindent{3em}
% Redefine representation for chapter (and section) counters
\renewcommand\cftchappresnum{CHAPTER }
\renewcommand\thechapter{\Roman{chapter}}
\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\centering}{CHAPTER \thechapter}{20pt}{\Huge}
\begin{document}
\pagenumbering{roman}
\setcounter{page}{7}
\tableofcontents
\clearpage
\pagenumbering{arabic}
\chapter{INTRODUCTION}
\section{Background}
\section{Objectives}
\chapter{REVIEW}
\section{Test Section}
\section{AnotherTest Section}
\chapter{CODE}
\chapter{END}
\chapter*{APPENDIX}
\addcontentsline{toc}{chapter}{APPENDIX}
\end{document}
答案2
您可以使用\renewcommand{\chaptername}{}
来删除章节标题中的“章节”。
如果您还想将章节标题的两行居中,请添加:
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\centering}{\thechapter}{20pt}{\Huge}
让你的 MWE 看起来像这样:
\documentclass{report}
\usepackage{tocloft}
\addtocontents{toc}{~\hfill{\small Page}\par}
\renewcommand\contentsname{CONTENTS}
\renewcommand{\chaptername}{}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\centering}{\thechapter}{20pt}{\Huge}
% Centered title for ToC
\renewcommand{\cfttoctitlefont}{\hfill\Huge\bfseries}
\renewcommand{\cftaftertoctitle}{\hfill}
% Leaders for chapter entries
\renewcommand\cftchapdotsep{\cftdotsep}
% Add space to account for new chapter numbering schema
\renewcommand\cftchapnumwidth{8em}
\renewcommand\cftsecindent{3em}
% Redefine representation for chapter (and section) counters
\renewcommand\thechapter{CHAPTER \Roman{chapter}}
\renewcommand\thesection{\arabic{chapter}.\arabic{section}}
\begin{document}
\pagenumbering{roman}
\setcounter{page}{7}
\tableofcontents
\clearpage
\pagenumbering{arabic}
\chapter{INTRODUCTION}
\section{Background}
\section{Objectives}
\chapter{REVIEW}
\section{Test Section}
\section{AnotherTest Section}
\chapter{CODE}
\chapter{END}
\chapter*{APPENDIX}
\addcontentsline{toc}{chapter}{APPENDIX}
\end{document}
并生产: