0

I'd like to remove the white space above all chapter numbers. I've tried both titlesec and etoolbox, neither of which worked. Here's my code:

documentclass[12]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{tikz-cd}
\usepackage{enumerate}
\usepackage{tocloft}
\usepackage{parskip}
\usepackage{indentfirst}
\setlength{\parindent}{1cm}
\usepackage{setspace}
\usepackage[nottoc]{tocbibind}
\usepackage{sectsty}
\renewcommand{\cftchapfont}{\normalfont}
\renewcommand{\cftchappagefont}{\normalfont}
\renewcommand{\cfttoctitlefont}{\hfill \Large}
\renewcommand{\cftaftertoctitle}{\hfill\hfill}
\renewcommand{\contentsname}{Table of Contents}
\chapternumberfont{\centering \Large}
\chaptertitlefont{\centering \Large}
\sectionfont{\large}

\begin{document}

\input{Titlepage} \pagenumbering{roman}

\setcounter{page}{2}

\doublespacing

\tableofcontents

\pagebreak

\pagebreak \pagenumbering{arabic}

\chapter{} \input{chapters/Preliminaries}

\chapter{} \input{chapters/chapter2}

\chapter{} \input{chapters/chapter3}

\chapter{} \input{chapters/chapter4}

\bibliographystyle{plain} \bibliography{bibliography.bib} \end{document}

DannyS
  • 1
  • Welcome to TeX Stack Exchange! Help us help you by making a minimal example that we can typeset to see what you see, and clarify what you mean by white space above the chapter numbers. – Ethan Duckworth Jul 07 '22 at 19:40
  • @EthanDuckworth It's hard to create a working example since I'm inputing my chapters from a different file. By white space I mean the space above say "Chapter 1" from top of the page. I believe by default its 50 pts, but I'm trying to make it 1 inch. – DannyS Jul 07 '22 at 19:44
  • When you say "I tried titlesec and etoolbox and neither worked", please supplement that with what you actually did when you "tried". It is possible that your attempt almost worked except for a small mistake somewhere. – Willie Wong Jul 07 '22 at 20:00

2 Answers2

1
\documentclass{report}
\usepackage{titlesec}

\titleformat{\chapter}[display]{\huge}{\chaptertitlename\ \thechapter.}{1ex}{}{}
\titlespacing{\chapter}{0pt}{0pt}{0pt}

\begin{document}

\tableofcontents

\chapter{}
Text
\end{document}

The three length arguments to \titlespacing are, in order, space on left, space above, and space below.

In your comment you say you want the Chapter number to be set 1 inch from "top of the page". So you will have to do some math depending on your margin size. If you have 1 inch margins, you want to set the space above to be 0pt.

As written there will be space below "Chapter 1". This is because titlesec reserves vertical space for the chapter title to be printed beneath it. You can get rid of it by issuing the [nostruts] option so that the space it not reserved.

As an aside: as mentioned in the titlesec documentation, if you want to change the spacing of \part and \chapter, you must also call \titleformat. Even if you like everything about the default \chapter formatting except for spacing, you still need to call \titleformat and try to reproduce the default by yourself for \titlespacing to work.

Willie Wong
  • 24,733
  • 8
  • 74
  • 106
  • Could you please explain how to set margins to 1 inch? This is what I've used: \topmargin=0in \headheight=0in \headsep=0in \textheight=9in \oddsidemargin=0in \textwidth=6.5in But then using your code, it still seems to be larger than 1 inch. And then there is also an issue with the table of contents heading. How can I make that 1 inch from the top of the page as well? Thanks! – DannyS Jul 08 '22 at 03:07
  • Setting margins can be done using the geometry package. Search this site for more info. For the extra space: it turns out that for chapter headings titlesec inserts some extra space (undocumented in its manual). See https://tex.stackexchange.com/questions/59389/package-titlesec-adds-extra-space-on-top-of-chapter-despite-commands-to-the-co for a discussion and a solution. – Willie Wong Jul 08 '22 at 14:06
1

If you do not want to read the titlesec documentation it is easy to change the 50pt added to the chapter head.

Add before \begin{document}

\usepackage{showframe}% only to show the margins
%*********************************** added <<<<<<<<<<<<
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}{\vspace*{50\p@}}{\vspace*{-30\p@}}{}{}
\makeatother
%********************************

to go from

a

to

b

Simon Dispa
  • 39,141