Page LayoutClearing Headers and Adding Basic Chapter Names in Scrbook

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ck2018
Posts: 11
Joined: Wed Oct 17, 2018 12:21 pm

Clearing Headers and Adding Basic Chapter Names in Scrbook

Post by ck2018 »

I'm trying to:
  • clear the header in order to stop the names of my chapters appearing in the header of every page after the first;
  • make the chapter name appear centered on the first page of the chapter as a single Roman numeral in the same font as the body text (but in bold).
I've tried numerous ways (e.g. fancyhdr) of changing the header, but they all seem to have incompatibilities with other things that I'm using (e.g. koma fonts).

Code: Select all

\documentclass[12pt,openany]{scrbook}
\usepackage{fontspec}
\setmainfont{FreeSerif}
\setsansfont{FreeSans}
\setmonofont{FreeMono}
\addtokomafont{disposition}{\rmfamily}
\author{author}
\date{date}
\title{title}

\sloppy
\usepackage[none]{hyphenat}
\renewcommand{\chaptername}{}
\renewcommand{\thechapter}{}
\usepackage{paracol}
\usepackage{microtype}
\usepackage[
    paperwidth=6in,
    paperheight=9in,
    inner=0.6in,
    outer=0.6in,
    bindingoffset=0.15in,
    top=0.6in,
    bottom=0.6in,
    twoside]{geometry}
\usepackage{scrpage2} 
\pagestyle{plain}
    

\begin{document}
\setlength{\columnsep}{3em}
\setlength{\parskip}{\baselineskip}
\maketitle

\chapter{I}

\begin{paracol}{2}
\begin{leftcolumn}
bla
\end{leftcolumn}
\begin{rightcolumn}
bla
\end{rightcolumn}
\enddocument
My latest attempt to fix this involves calling \pagestyle{plain}, which did suppress the headers but also removed the page numbers (which I would have expected from {empty}) and resulted in error message:
Package `scrpage2' is obsolete.\MessageBreak
You should not longer use package `scrpage2'.\MessageBreak
You should replace usage of package `scrpage2'\MessageBreak
by `scrlayer-scrpage'}
The chapter headings (i.e. the Roman numerals) look the way I want them to in terms of size and font, but they are indented (because I've suppressed the number that appears automatically) and are not centered. I'm currently using XeTex, but everything seems to work in LuaTex as well (with the same error message). After hours of experimenting with various options only to find that they are either incompatible with other elements or generate problems of their own, I'd appreciate any help. :D
Last edited by ck2018 on Thu Oct 18, 2018 5:37 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Clearing Headers and Adding Basic Chapter Names in Scrbook

Post by Stefan Kottwitz »

Welcome to the forum!

The error is actually just a warning. It means that you should remove \usepackage{scrpage2}. Add instead:

Code: Select all

\usepackage{scrlayer-scrpage}
\pagestyle{scrplain}
Forget fancyhdr. scrlayer-scrpage is the suitable replacement for the scrbook class and KOMA-Script in general. You can read about it in the scrguien manual.

This

Code: Select all

\renewcommand{\chaptername}{}
\renewcommand{\thechapter}{}
is strange. It breaks things, actually it seems you don't want automatically numbered chapters at all, but you want big Roman numbers as centered kind of headings, right? So perhaps do it without chapters, especially if you don't need references to chapters and no table of contents with chapters.

Stefan
LaTeX.org admin
ck2018
Posts: 11
Joined: Wed Oct 17, 2018 12:21 pm

Clearing Headers and Adding Basic Chapter Names in Scrbook

Post by ck2018 »

Stefan Kottwitz wrote:Welcome to the forum!
Thanks!
Stefan Kottwitz wrote:The error is actually just a warning. It means that you should remove \usepackage{scrpage2}. Add instead:

Code: Select all

\usepackage{scrlayer-scrpage}
\pagestyle{scrplain}
Forget fancyhdr. scrlayer-scrpage is the suitable replacement for the scrbook class and KOMA-Script in general. You can read about it in the scrguien manual.
Being overcautious, I usually treat a warning as being as good as an error! :D

That works, but the page numbers are now falling off the page; only the top half of each number is visible. I had actually just stumbled across a workaround: changing the document class and compiling in XeLaTex.

Code: Select all

\documentclass[twoside]{report}
This removes the header but retains the page-numbering. It evens removes the white space before the Roman numerals, which was a consequence of suppressing the auto-generating chapter-number. It doesn't center the numerals, and the 50pt space above them is annoying, but it's certainly a big improvement.
...actually it seems you don't want automatically numbered chapters at all, but you want big Roman numbers as centered kind of headings, right? So perhaps do it without chapters, especially if you don't need references to chapters and no table of contents with chapters.
You're right that I want centered Roman numerals as headings; however, I would like to have a contents page. I'll get there...

EDIT:

This kind of works for the chapter headings.

Code: Select all

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}{50\p@}{-50pt}{}{}
\patchcmd{\@makeschapterhead}{50\p@}{-50pt}{}{}
\makeatother
It doesn't center them, and I'll have to find out how to remove the space below at some point. Ideally, the chapter-heading should appear on the line below the top margin and skip only line below. There's no need for all this extra space.

SECOND EDIT:

This works even better.

Code: Select all

\usepackage{titlesec}
\titleformat{\chapter}[display]
    {\normalfont\filcenter\large\bfseries}{\chaptertitlename\ \thechapter}{0pt}{\Large}
\titlespacing*{\chapter}{0pt}{0pt}{0pt}
It centers the chapter and removes the unnecessary space below it, but despite what I read in the manual, it doesn't seem to remove the space above it. Still, it's an improvement.
Post Reply