1

I'm using the code below. The margin for my report is 2cm for top, right and bottom, 4cm for left. The margin setting works for my second page. However, it does not work for my page in which the chapter title is located. May I know how can I solve it? Besides, I need to put my chapter title and chapter number at the same row. Thanks for your help.

\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}
  • Adding the showframe option to geometry, I can see no such problem. Does the code you posted reproduce the problem for you? – Bernard Mar 18 at 10:11
  • @Bernard Ya. There is distance between chapter title and the frame, which does not happen for the second page. – user3089201 Mar 18 at 10:47
  • Oj! That is a problem w.r.t. the top margin? That is the normal behaviour. You need to load titlesecin the place of sectsty to change it. – Bernard Mar 18 at 11:05
  • Sorry. I have a question. I tried your suggestion. But the console output produced this: Undefined control sequence. <recently read> \chapternumberfont l.23 \chapternumberfont{\nohang\centering\small\MakeUppercase} %to forma... . I tried to run it using pdfLaTeX or XeLaTeX. – user3089201 Mar 18 at 11:39
  • Did you remove the loading of sectsty? As they tackle the same things, it's incompatible with titlesec. – Bernard Mar 18 at 11:51
0
\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.