我正在使用下面的代码。我的报告的边距为顶部、右侧和底部 2 厘米,左侧 4 厘米。边距设置适用于我的第二页。但是,它不适用于章节标题所在的页面。请问我该如何解决?此外,我需要将章节标题和章节编号放在同一行。感谢您的帮助。
\documentclass[12pt,a4paper]{report}
%%%%%%%%Package
\usepackage{anysize}
\usepackage{faktor}
\usepackage{placeins}
\usepackage{float}
\usepackage{fancyhdr}%for page number font
\usepackage{lmodern}%also for page number font
\usepackage{booktabs, calc, cleveref}
\usepackage{mathptmx}%Font: Times New Roman
\usepackage{setspace} %Set spacing between lines
\doublespacing
\usepackage[font={small},labelfont=bf]{caption}%For figure's caption
\usepackage[titles]{tocloft} %Table of contents
\usepackage{sectsty}%used to format chapter title to be centre etc.
\chapternumberfont{\nohang\centering\small\MakeUppercase} %to format the font for the 'Chapter' number
\chaptertitlefont{\nohang\centering\small\MakeUppercase}
\sectionfont{\fontsize{12}{15}\selectfont}
%Set Margin
\usepackage[left=4cm, right=2cm, top=2cm, bottom=2cm, footskip=1cm]{geometry}
%%%%%%%
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters dots
\renewcommand\cftchappresnum{CHAPTER } % prefix "Chapter " to chapter number in ToC
\cftsetindents{chapter}{0em}{6em} % set amount of indenting
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{\thepage}
\fancypagestyle{plain}{
\fancyfoot{}
\fancyfoot[R]{\fontsize{10pt}{10pt}\selectfont\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
\pagestyle{plain}
\begin{document}
\chapter{Introduction}
This is my file.
\newpage
This is my file2.
\end{document}
答案1
\documentclass[12pt,a4paper]{report}
%%%%%%%%Package
\usepackage{array}
\usepackage{anysize}
\usepackage{faktor}
\usepackage{placeins}
\usepackage{float}
\usepackage{enumerate}
\usepackage{fancyhdr}%for page number font
\usepackage{lmodern}%also for page number font
\usepackage[pdftex]{graphicx}
\usepackage{caption}
%Set Margin
\usepackage[left=4cm, right=2cm, top=2cm, bottom=2cm, footskip=1cm, showframe]{geometry}
\usepackage{mathptmx}%Font: Times New Roman
\usepackage{setspace}%double spacing
\setstretch{2}%or use \doublespacing
\usepackage[font={small},labelfont=bf]{caption}
\usepackage[titles]{tocloft}
\usepackage[notquote]{hanging}%for hanging indentation, used in the List of Publications section, [notquote] required so file doesn't crash
\usepackage{titlesec}%used to format chapter title to be centre and within margin.
\titleformat{\chapter}[hang]{\bf}{\centering\normalsize\MakeUppercase\chaptername~\thechapter}{1ex}{\centering\MakeUppercase\normalsize}
\titlespacing{\chapter}{0cm}{*-6}{*6}
\titleformat{\section}{\normalfont\fontsize{12}{15}\bfseries}{\thesection}{1em}{}
\usepackage{tikz}
%%%%%%%
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters dots
\renewcommand\cftchappresnum{CHAPTER } % prefix "Chapter " to chapter number in ToC
\cftsetindents{chapter}{0em}{6em} % set amount of indenting
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
%%%%
\fancypagestyle{plain}{
\fancyfoot{}
\fancyfoot[R]{\fontsize{10pt}{10pt}\selectfont\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
\pagestyle{plain}
%%%%
\renewcommand{\contentsname}{Table of Contents}%Change 'Contents' to 'Table of Contents'
\begin{document}
\addcontentsline{toc}{chapter}{TABLE OF CONTENTS}
\tableofcontents
\pagenumbering{arabic}
\setcounter{page}{1}
%Chapter 1
\chapter{\MakeUppercase{INTRODUCTION}}
%Background of study
\section{Background of study}
xxx
%%%%%%%%%%%%%%
\chapter{\MakeUppercase{Literature Review and Some Preliminaries}}
\section{A brief overview}
xxx
\end{document}