1

enter image description here

I tried to delete all the geometry and delete the usepackage{geometry} and all the margins and everything but end up the TOC is still away from my top a lot. I want it to have 50mm away from the top. i've printed it out and measured it. It's 85mm..

Even my list of figures, tables, listings are all 85mm...

\documentclass[12pt, a4paper, oneside]{report}
\usepackage[T1]{fontenc}
\usepackage{mathptmx} %times font
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{hyperref}
\usepackage{setspace}
\usepackage[english]{babel} %roman & arabic label page
\usepackage[top=50mm, bottom=50mm, left=45mm, right=45mm]{geometry}
%\usepackage{tocbibind} %for hyperref
\usepackage{indentfirst}
\usepackage{apacite} %cite apa
\usepackage{array} %for table width
\usepackage{listings} %codes
\usepackage{caption} % code caption
\usepackage{color} % code caption
\usepackage{xcolor} %code caption
\usepackage{titlesec} % set section/subsection fontstyle & fontsize

\titleformat{\section}
{\normalfont\fontsize{14}{14}\bfseries\itshape}{\thesection}{1em}{}

\titleformat{\subsection}
{\normalfont\fontsize{12}{12}\bfseries\itshape}{\thesubsection}{1em}{}


\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}

\hypersetup{
colorlinks=true, %set true if you want colored links
linktoc=all,     %set to all if you want both sections and subsections     linked
linkcolor = black,  %choose some color if you want links to stand out
urlcolor=blue, % for \url
citecolor=black, 
}

\pagenumbering{Roman}

\begin{document}
\input{CoverPage}
\thispagestyle{empty}
\cleardoublepage

\input{TitlePage}
\thispagestyle{empty}
\cleardoublepage


\phantomsection
\addcontentsline{toc}{chapter}{Copyright}
\input{CopyrightPage}
\setcounter{page}{1}
\cleardoublepage


\phantomsection
\addcontentsline{toc}{chapter}{Declaration}
\input{DeclarationPage}
\cleardoublepage


\phantomsection
\addcontentsline{toc}{chapter}{Acknowledgement}
\input{AcknowledgementPage}
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{Management Summary}
\input{ManagementSummaryPage}
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{Table of Contents}
\renewcommand\contentsname{Table of Contents}
\tableofcontents
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{List of Algorithms}
\renewcommand\lstlistlistingname{List of Algorithms}
\lstlistoflistings
\cleardoublepage

% % (1) =========================================

\pagenumbering{arabic}
\phantomsection
\addcontentsline{toc}{chapter}{Chapter 1 : Introduction}
\setcounter{chapter}{1}
\input{Chapter1}
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{Chapter 2 : Background Study }
\setcounter{chapter}{2}
\input{Chapter2}
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{Chapter 3 : Requirements \& Design}
\setcounter{chapter}{3}
\input{Chapter3}
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{Chapter 4 : Implementation Plan}
\setcounter{chapter}{4}
\input{Chapter4}
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{Chapter 5 : Conclusion}
\setcounter{chapter}{5}
\input{Chapter5}
\cleardoublepage

\phantomsection
%\addcontentsline{toc}{chapter}{Reference}
\setcounter{chapter}{6}
\input{References}
\cleardoublepage

\phantomsection
\addcontentsline{toc}{chapter}{Appendix}
\setcounter{chapter}{7}
\input{Appendix}
\cleardoublepage


\end{document}
10
  • 1
    Presumably that is the design for chapter headings in your class. since you have given no indication of the input, impossible to say anything. – David Carlisle Sep 15 '15 at 10:21
  • 1
    As always, please post a MWE showing this problem. This is just the design of either \chapter* or \section* of your document – daleif Sep 15 '15 at 10:22
  • 1
    No minimal working example, no answer. – yo' Sep 15 '15 at 10:23
  • Well, your edit is nice, but this is not a full example, starting at \documentclass and ending at \end{document}. Please, try to help us help you. Thanks. – yo' Sep 15 '15 at 10:30
  • I'm pretty sure that if you try with \chapter*{Introduction} the result will be the same. If the question is “how to push the title of an unnumbered chapter up to the text block border?” then it may receive an answer, provided you tell what document class you're using. – egreg Sep 15 '15 at 10:30
3

What you want is: to modify the spacing around chapter titles. This is done for instance by using the package titlesec:

\usepackage{titlesec}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries}%
  {\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*\chapter{0pt}{10pt}{40pt}

You can fiddle with the values 10pt and 40pt to fine-tune the spacing to your liking.


Needed to say, there is more comments I have on your code:

  • I don't understand **why you set the chapter counter each time, and why you use \phantomsection and \addcontentsline manually. That seems to be a big abuse of the system, things should be surely done another way.

  • Note that if you want chapters to start on odd page, you can't use [oneside] and you have to add [openright] in the report class. The book class set [twoside,openright] as default.

  • Instead of manually adding ToC, LoT etc. in the table of contents, you better use the package {tocbibind}.

  • hyperref should be loaded after most other packages. color is not needed if you load xcolor.

  • It's better not to use explicit \fontsize{}{} command but rely on the standard commands; 12pt is \normalsize for your setup, and 14pt is \large. If you decide to use \fontsize, the 2nd number should be larger by ~20%, so \fontsize{12}{14} and \fontsize{14.4}{17} would have been better, for instance.

In the end, your code could look like this:

\documentclass[12pt, a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage{mathptmx} %times font
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{setspace}
\usepackage[english]{babel} %roman & arabic label page
\usepackage[top=50mm, bottom=50mm, left=45mm, right=45mm]{geometry}
\usepackage{tocbibind} %for hyperref
\usepackage{indentfirst}
\usepackage{apacite} %cite apa
\usepackage{array} %for table width
\usepackage{listings} %codes
\usepackage{caption} % code caption
\usepackage{xcolor} % code caption

\usepackage{blindtext} % to provide some dummy text

\usepackage{titlesec}

\titleformat{\chapter}[display]{\normalfont\huge\bfseries}%
  {\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*\chapter{0pt}{10pt}{40pt}

\titleformat{\section}
{\normalfont\large\bfseries\itshape}{\thesection}{1em}{}

\titleformat{\subsection}
{\normalfont\normalsize\bfseries\itshape}{\thesubsection}{1em}{}

\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}

\usepackage{hyperref}

\hypersetup{
colorlinks=true, %set true if you want colored links
linktoc=all,     %set to all if you want both sections and subsections     linked
linkcolor = black,  %choose some color if you want links to stand out
urlcolor=blue, % for \url
citecolor=black, 
}

\begin{document}

% FRONTMATTER

\pagenumbering{Roman}

\renewcommand\contentsname{Table of Contents}
\tableofcontents

\listoffigures

\listoftables

\renewcommand\lstlistlistingname{List of Algorithms}
\lstlistoflistings

% MAINMATTER

\cleardoublepage
\pagenumbering{arabic}

\chapter{First Chapter}
\Blindtext


\chapter{Second Chapter}
\Blindtext


\end{document}
8
  • the 0pt 10pt and 40pt is what ah? as in 0pt is the beginning isit? 10 and 40 is?? o.o – Michimcchicken Sep 15 '15 at 11:01
  • and the {\chaptertitlename\ \thechapter}{20pt}{\Huge} can i use default and delete this line? o.o – Michimcchicken Sep 15 '15 at 11:02
  • @Michimcchicken This should make the default. If you don't use \titleformat{\chapter} at all, then \titlespacing*{\chapter} cannot do anything. – yo' Sep 15 '15 at 11:04
  • 1
    For the meaning of the dimensions in \titlespacing, read the titlesec documentation – yo' Sep 15 '15 at 11:06
  • 1
    @Michimcchicken You're welcome :) – yo' Sep 15 '15 at 11:12

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.