0

I have the following problem: I want to lift the title of each chapter (so there's less vertical free space) and put the number before. Which means the layout from default settings

*much free space*

Chapter 1

Intro

Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...

to

1. Intro

Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...

The thing is, I added, as shown in another question,

\documentclass[a4paper,12pt]{report}
\usepackage[latin1]{inputenc}\usepackage[german]{babel}
\usepackage{ngerman}\usepackage[T1]{fontenc}\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{lipsum}
\usepackage[nodisplayskipstretch,doublespacing]{setspace}\usepackage{fancyhdr}\usepackage{layout}\usepackage[top=25mm,bottom=25mm,left=3cm,right=3cm]{geometry}\usepackage{atbegshi}
\usepackage{float}
\usepackage{subfig}
\usepackage{rotating}
\usepackage{eurosym}
\usepackage{amsmath}\usepackage{amssymb}\usepackage{calc}
%\usepackage{color}\usepackage[table]{xcolor} % Do I need these when I include images with colors?
\usepackage{caption}\usepackage{section}\usepackage{csquotes}
\usepackage[style=numeric,sorting=none,backend=bibtex,inputenc=latin1]{biblatex}\addbibresource{Literatur.bib}\usepackage{listings}
\usepackage{hyperref}\usepackage[all]{hypcap}
\makeatletter
\def\@makeschapterhead#1{\vspace*{-50\p@}{\parindent 
%    \z@ 
\raggedright    \normalfont    \interlinepenalty\@M    \Huge \bfseries    \c@chapter    #1\par\nobreak    \vskip 20\p@}}
\makeatother
\setlength{\parindent}{0pt}
\begin{document}

\pagestyle{empty}
\newgeometry{top=25mm,bottom=25mm,left=3cm,right=3cm}
\include{titlepage} %This is the manually made title page plus a 2^nd page, which contains an acknowledgement.
\tableofcontents
\renewcommand{\baselinestretch}{2} %line pitch: double
\pagestyle{fancy}
\newgeometry{top=25mm,bottom=25mm,left=3cm,right=3cm}
\fancyhf{}
\renewcommand{\headrulewidth}{1pt}
\fancyhead[L]{\leftmark}
\renewcommand{\footrulewidth}{1pt}
\fancyfoot[R]{\thepage}
\include{Intro}
\include{nextpart} %Every chapter is in an exxtra .tex-file.
\end{document}

And here the code of Intro.tex:

\fussy %Only in first chapter.
\chapter{Intro}
\thispagestyle{fancy} %I changed in titlepage.tex; appearing only in this chapter.
\pagenumbering{arabic} %I changed in titlepage.tex; appearing only in this chapter.
    Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...

But I get an extra "502040 " in my text right in front of the content of each chapter and also as an extre line in my list of tables. I think I just misspelled some commands, but I don't get which ones they could be. The .log-file doesn't tell me (or I'm just blind).

Actual output:

Intro

502040 Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...

Maybe some package is confusing my compiler because I also get an Illegal parameter number in definition of \rmn@originalTeX.<to be read again> } \begin{document}.-error which repeats 8 times. But this error seems to do nothing. (Sorry for being so uninformed.)

  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Null Jan 14 '16 at 14:35
  • The spacing before the chapter title is controlled by \vspace*{-50\p@}. This can't be changed directly. – user31729 Jan 14 '16 at 15:17
  • 2
    Use a package dedicated to this task, such as titlesec. – Bernard Jan 14 '16 at 15:59
2

As was suggested to you in the comments, load the titlesec package. Then add the following commands:

\titleformat{\chapter}{\normalfont\bfseries\Large}{\thechapter.\quad}{0pt}{}
\titlespacing{\chapter}{0pt}{-50pt}{40pt}

The second one is what you're looking for. The values are respectively:

  • left space
  • space before (above)
  • space after (below)

So you get

enter image description here

and here's the code:

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{titlesec}
\usepackage{lipsum}

\titleformat{\chapter}{\normalfont\bfseries\Large}{\thechapter.\quad}{0pt}{}
\titlespacing{\chapter}{0pt}{-50pt}{40pt}% left space, top space, bottom space

\begin{document}
\chapter{This is my first chapter}
\lipsum[1]
\end{document}
  • I just can't install/use the titlesec-package. The error output says "File 'titlesec.sty' not found. And it gives a fatal error while loading the next package... – Nepumuk Jan 14 '16 at 19:50
  • @Nepumuk Do you use Tex Live? You should update your Tex distribution. – Alenanno Jan 14 '16 at 20:59
  • I use TeXnicCenter with MikTeX. I updated it, but the only changing thing is that I don't get the error anymore, but the geometry is still the same. I think \titleformat{\chapter}{\normalfont\bfseries\Large}{\thechapter.\quad}{0pt}{} \titlespacing{\chapter}{0pt}{-50pt}{40pt} needs to be after the preamble.I did so and now it runs. But I still got another arror (which I didn't tell so far). Can I upload a *.jpg file here? – Nepumuk Jan 16 '16 at 19:40
  • Can I also have the normal formatting for specific chapters in the same document? – Nepumuk Jan 16 '16 at 20:23
  • @Nepumuk No, they should be in the preamble, but I'm not sure why it works for you that way. Something is odd. What error are you getting? Regarding the second question, that needs to be a follow-up question because it's separated from this one. – Alenanno Jan 16 '16 at 20:43

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.