I'm trying to reduce the number of packages I'm loading in my documents and I read on the KOMA documentation (and elsewhere) that it can define page styles better than fancyhdr
. But each time I try to set up scrpage2
I get weird results, such as with the wrong section titles or positioning of elements. How can I rewrite my fancyhdr
layout to scrpage2
?
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LO]{\textit{\nouppercase{\scshape \mytitle{}}}}
\fancyhead[RE]{\textit{\nouppercase{\scshape \thechapter. \leftmark{}}}}
\fancyfoot[CE,CO]{\thepage{}}
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[CE,CO]{\thepage{}}
}
\fancypagestyle{preface}{
\fancyhf{}
\fancyhead[RE]{\textit{\nouppercase{\scshape \leftmark{}}}}
\fancyhead[LO]{\textit{\nouppercase{\scshape \mytitle{}}}}
\fancyfoot[CE,CO]{\thepage{}}
}
The preface
style is used for the pages before Chapter 1; other pages just use the default fancy
style.