[Tex/LaTex] How to replace fancyhdr to a right scrbook way

fancyhdrkoma-script

I've seen it is not right to use fancyhdr with scrbook, I've got a code with fancyhdr and I want to replace it to scrbook. This is my code:

\usepackage{fancyhdr}

\pagestyle{fancy}
\lhead{TEMA 13}
\rhead{\thepage }
\chead{Polinomios}
\rfoot{Oposiciones}
\rhead{\thepage }
\renewcommand{\footrulewidth}{0.4pt} 
\renewcommand{\headrulewidth}{0.4pt}

Best Answer

I guess your document is oneside? Then you can use

\documentclass[oneside]{scrbook}

\usepackage[headsepline,footsepline,manualmark]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{TEMA 13}
\chead{Polinomios}
\ohead{\pagemark}
\ofoot{Oposiciones}
\cfoot[\pagemark]{}
\addtokomafont{pageheadfoot}{\upshape}

\usepackage{blindtext}% dummy text
\begin{document}
\blinddocument
\end{document}

If your document is twoside there are two cases:

  1. TEMA 13 should be on the left hand side on even pages and on the right hand side on odd pages? Then you can use the same code as for the oneside option because the i in \ohead means "inner".

  2. TEMA 13 should be on the right hand side on both the even and the odd pages? Then you have to use \lehead and \lohead (le means left even, lo left odd).

Code for the second case:

\documentclass{scrbook}

\usepackage[headsepline,footsepline,manualmark]{scrlayer-scrpage}
\clearpairofpagestyles
\lehead{TEMA 13}\lohead{TEMA 13}
\chead{Polinomios}
\rehead{\pagemark}\rohead{\pagemark}
\lefoot{Oposiciones}\lofoot{Oposiciones}
\cfoot[\pagemark]{}
\addtokomafont{pageheadfoot}{\upshape}

\usepackage{blindtext}% dummy text
\begin{document}
\blinddocument
\end{document}