0

I know there are related questions, but I am still not getting it to work.

I have a long document with 3 chapters, and in each chapter, there are sections such as "1.2.3" for Chapter 1, section 2.3.

I need the chapters to appear on even pages, on the right. The section (only the first level, i.e. 1.2) needs to appear odd pages, on the left.

I used the following code:

\documentclass[DIV12, a4paper, 12pt, listof=totocnumbered, bibliography=totoc]{book}
\title{Dissertation}
\author{xx}
\usepackage{a4wide}
\usepackage{datetime}
\usepackage{lscape}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[onehalfspacing]{setspace}
\usepackage{float, afterpage, rotating, graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz, epstopdf,pgfplots}
\usepackage{longtable, booktabs, tabularx}
\usepackage{fancyvrb, moreverb, relsize}
\usepackage{eurosym, calc, chngcntr}
\usepackage{amsmath, amssymb, amsfonts, amsthm, bm}
\usepackage{mathtools}
\DeclareMathOperator*{\argmin}{arg\,min}
\DeclareMathOperator*{\argmax}{arg\,max}
\usepackage[skip=5pt]{caption} %add labelfont={bf} as option to make 'Table 1.x' or 'Figure 3.x' bold (but not rest of caption)
\usepackage{mdwlist}
\usepackage{xfrac}
\DeclareUnicodeCharacter{FB01}{fi}
\DeclareUnicodeCharacter{FB02}{fl}
\usepackage{setspace,geometry}
\usepackage{xcolor}
\usepackage{lmodern}
\usepackage{upgreek}
\usepackage{afterpage}
\usepackage{wrapfig}
\usepackage{multirow, makecell}
%\usepackage{fancyhdr}
\usepackage[toc]{glossaries}
\usepackage{subcaption}
%\usepackage{lipsum}  
\usepackage{eurosym}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{tabularx}
%\usepackage{abstract}
\usepackage{graphicx}
\usepackage[hyphens]{url}
\usepackage{acronym}
\usepackage[english]{babel}
\usepackage[round]{natbib}
\usepackage[nottoc]{tocbibind}
\usepackage{pdfpages}

\newdateformat{monthyeardate}{%
  \monthname[\THEMONTH], \THEYEAR}


\geometry{a4paper, headsep=0.6cm, left=33mm, right=33mm, top=25mm, bottom=20mm} %headsep verschiebt die Kopfzeile (Standard ist etwa bei 1cm)



% Kopfzeile anpassen
\usepackage[autooneside=false,headsepline]{scrlayer-scrpage}% Default headsepline width = 0.4pt
\automark[subsection]{section}
\clearscrheadfoot
\cfoot[\pagemark]{\pagemark}
\ohead{\ifstr{\rightbotmark}{\leftmark}{}{\rightbotmark}}
\ihead{\MakeTextUppercase{\leftmark}}



\begin{document}

\chapter{Test Chapter}

\section{Test Section}

\subsection{Test Subsection}

xxxxxxxx

\clearpage

xxxxxxxxx

\clearpage

xxxxxxxxx

\clearpage

xxxxxxxxx

\end{document}
3
  • Does \clearscrheadings \clearscrplain \ihead[\headmark]{\headmark} \cfoot[\thepage]{\pagemark} \pagestyle{scrheadings} give the desired result?
    – leandriis
    Feb 27 '20 at 21:20
  • Yes, I used: \usepackage[autooneside=false,headsepline]{scrlayer-scrpage}% Default headsepline width = 0.4pt \automark[section]{chapter} \clearscrheadings \clearscrplain \ihead[\headmark]{\headmark} \cfoot[\thepage]{\pagemark} \pagestyle{scrheadings} Is there a way to change "Chapter 1. Test Chapter" to "1. Test Chapter" ?
    – MANGo 92
    Feb 27 '20 at 21:48
  • \clearscrheadfoot is a short version of \clearscrheadings\clearscrplain. These three commands are outdated. They should be replaced by \clearpairofpagestyles and \clearmainofpairofpagestyles\clearplainofpairofpagestyles.
    – esdd
    Feb 27 '20 at 22:55
3

You can use

\usepackage[automark,headsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot*{\pagemark}
\ihead{\headmark}

\clearpairofpagestyles replaces the outdated \clearscrheadfoot. \cfoot*{\pagemark} is a short version of \cfoot[\pagemark]{\pagemark}. If there should be no chapter prefix in header add

\renewcommand\chaptermarkformat{\thechapter.\enskip}

Example without the unrelated stuff:

\documentclass[a4paper,12pt]{book}
\usepackage[english]{babel}
\usepackage{geometry}
\geometry{headsep=0.6cm, left=33mm, right=33mm, top=25mm, bottom=20mm,
  headheight=14.5pt% <- added
}

\usepackage[automark,headsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\cfoot*{\pagemark}
\ihead{\headmark}
\renewcommand\chaptermarkformat{\thechapter.\enskip}

\usepackage{blindtext}% only for dummy text

\begin{document}
\tableofcontents
\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument
\end{document}

enter image description here


Additional remark: You have to clean up your preamble. You load the standard class book - so you have to remove the KOMA-Script options DIV=12, listof=totocnumbered and bibliography=totoc. Package a4wide is outdated and useless in the example because you are using geometry. Do not load packages twice (graphicx, amsfonts, eurosym, tabularx, booktabs). Package pgfplots loads packages tikz, xcolor, graphicx, rotating automatically. With an uptodate TeX distribution package chngcntr and package inputenc with option utf8 are not needed.

2
  • Is there an easy way to have the page numbers in the header? So left alligned for chapter level pages, and right alligned for section level pages.
    – MANGo 92
    Mar 6 '20 at 17:05
  • 1
    Replace \cfoot*{\pagemark} by \ohead*{\pagemark}.
    – esdd
    Mar 6 '20 at 17:51

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.