8

I try to use scrreprt and fancyhdr for getting the chapter at the head of even pages left and the section at odd pages right:

 \documentclass[12pt,a4paper,twosides]{scrreprt}
 \usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhead[LE]{\rightmark} 
 \fancyhead[RO]{\leftmark} 
 \fancyhead[LO]{}
 \fancyhead[RE]{}
 \fancyfoot[C]{\thepage} 

But actually I want to use scrreport without the twoside argument, so that the pages are all the same (margins left etc.). When I use

 \documentclass[12pt,a4paper]{scrreprt}
 \usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhead[LE]{\rightmark} 
 \fancyhead[RO]{\leftmark} 
 \fancyhead[LO]{}
 \fancyhead[RE]{}
 \fancyfoot[C]{\thepage} 

I just get chapter and section at the head of every page. Is there a way to define odd and even pages without the twoside argument by setting scrreprt? Or exists a simple package for doing this?

5
  • 4
    Do not use »fancyhdr« with classes from »KOMA-Script«. Migrate to the »scrlayer-scrpage« package (or »scrpage2« in older versions). They are described in the »KOMA-Script« user guide. Feb 20, 2014 at 9:59
  • @ThorstenDonig: fancyhdr could also be used with KOMA-Script classes, as clearly is written in KOMA-Script documentation. But of course it is much better to use the dedicated KOMA-Script package(s).
    – Speravir
    Feb 20, 2014 at 22:09
  • @Speravir: But it is not recommended because it does not support the diverse interfaces that »KOMA-Script« offers to modify certain elements. And I didn't say with any word that it can't be used. Feb 21, 2014 at 8:28
  • @ThorstenDonig: I understood your first sentence in comment this way …
    – Speravir
    Feb 21, 2014 at 20:49
  • @Speravir: Then you obviously misunderstood that sentence. There is a significant difference in "don't use" and "you can't use". Feb 22, 2014 at 7:42

1 Answer 1

15

You can use the twoside=semi option so you have equal margins.

Then, to achieve what you want, we use the scrlayer-scrpage package instead of fancyhdr which is not recommended for KOMA classes.

We load scrlayer-scrpage in this way

\usepackage[automark,headsepline]{scrlayer-scrpage}

The automark option is to automatically create running headers, while headsepline is to print the header line in non-plain pages.

At this point we clear headers and footers for all pages with the command

\clearpairofpagestyles

and then, with the following lines,

\cfoot[\pagemark]{\pagemark}
\lehead{\headmark}
\rohead{\headmark}

we set the page number at the center of the footer in all pages and the running headers in non-plain ones.

And, finally, we say that we want to use the newly created style with the command

\pagestyle{scrheadings}

MWE:

\documentclass[12pt,a4paper,twoside=semi]{scrreprt}

\usepackage{lipsum} % only for the example

\usepackage[automark,headsepline]{scrlayer-scrpage}

\clearpairofpagestyles
\cfoot[\pagemark]{\pagemark}
\lehead{\headmark}
\rohead{\headmark}
\pagestyle{scrheadings}

\begin{document}

\chapter{Test}

\lipsum[1-5]

\section{A section}

\lipsum[1-5]

\end{document} 

Output:

enter image description here

11
  • Thats nice so far, thank you for that! But there are two more points, which makes it complete: 1. A horizontal line between the header and text would be nice, like in the fancyhdr package. 2. I got a two sides introduction and at the second page I then get a header too. How could one avoid the header at one page?
    – dalvo
    Feb 20, 2014 at 11:13
  • @dalvo I've completely rewritten the answer to achieve what you want. Feb 20, 2014 at 12:28
  • Instead of scrpage2, shouldn't you use scrlayer-scrpage?
    – Manuel
    Feb 20, 2014 at 12:58
  • 2
    @dalvo To avoid the headers for one page, issue a \thispagestyle{scrplain} Feb 20, 2014 at 12:59
  • 1
    @dalvo Add the line \renewcommand*{\headfont}{\normalfont\normalcolor\slshape\small} in the preamble to achieve this. Feb 21, 2014 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .