[Tex/LaTex] Moving page numbers from footer to header with scrbook

header-footerkoma-scriptscrbook

I'm trying to get a nice novel format in LaTeX. I found the following:

% WITHOUT BLEED
% US Trade => 6x9
\documentclass[paper=6in:9in,pagesize=pdftex,
               headinclude=on,footinclude=on,12pt]{scrbook}
%
% Paper width
% W = 6in
% Paper height
% H = 9in
% Paper gutter
% BCOR = 0.5in
% Margin (0.5in imposed on lulu, recommended on createspace)
% m = 0.5in
% Text height
% h = H - 2m = 8in
% Text width
% w = W - 2m - BCOR = 4.5in
\areaset[0.50in]{4.5in}{8in}

This is perfect except for having the page numbers on the bottom. I did a lot of googling and found a way to remove the page numbers from the bottom and put them on the top. I inserted this right before \begin{document}

\usepackage{scrpage2}
\pagestyle{scrheadings}
\addtokomafont{pagenumber}{\oldstylenums}
\clearscrheadfoot %% <-----
\rehead[\pagemark]{\pagemark}
\lohead[\pagemark]{\pagemark}

But now this removes the chapter names from the top left (I think I can figure out how to fix that), and the bigger problem: I have page numbers on pages that shouldn't have page numbers, like the table of contents.

Really all I want to do is make a minor modification to the first block of code I copied and pasted, but I can't see how to do this.

Thanks in advance, and sorry if this has been asked before (I looked at many similar threads, but didn't see any that exactly answered this).

Best Answer

You have to add two commands to insert the chapter and the section into the header. Just add the lines

\lehead{\headmark}% left even head <===================================
\rohead{\headmark}% right odd head <===================================

to get the chapter heading and the section heading into the header of the uneven and the even pages.

Complete code blindtextcreates dummy text and showframe shows the typing area):

\documentclass[%
  paper=6in:9in,
  pagesize=pdftex,
  headinclude=on,
  footinclude=on,12pt
]{scrbook}
\areaset[0.50in]{4.5in}{8in}

\usepackage{blindtext} % to produce dummy text
\usepackage{showframe}

\usepackage{scrpage2}
\pagestyle{scrheadings}
\addtokomafont{pagenumber}{\oldstylenums}
\clearscrheadfoot %% <-----
\lehead{\headmark}% left even head <===================================
\rehead[\pagemark]{\pagemark}
\lohead[\pagemark]{\pagemark}
\rohead{\headmark}% right odd head <===================================


\begin{document}

\Blinddocument

\end{document}

and the result (header page 2):

enter image description here

Related Question