1. Redefining scrheadings
The redefinition of scrheading
is described in chapter 5 in the KOMAscript-manual.
Add the following three lines to your MWE:
\clearscrheadfoot
\ohead{\rightmark}
\cfoot[\pagemark]{\pagemark}
You manipulate chapter
or section
in the header by changing between \leftmark
and \rightmark
in the second line, i.e.
\ohead{\rightmark} % section-names in the header
\ohead{\leftmark} % chapter-names in the header
If you use the option twoside
to the class, you can use the command
\ohead{\headmark}
and have chapter
names in the left-side heading and section names in the right-side headings, automagically.
Page number x of y
To have page number as ‘6 of 10’, add the package lastpage and redefine the cfoot
to:
\cfoot[\pagemark]{\pagemark{} of \pageref{LastPage}}
NB! If you want the same page numbering in the part
- and chapter
-sides, add the same commands to the optional argument of \cfoot
, i.e.
\cfoot[\pagemark{} of \pageref{LastPage}]% for pagestyle `scrplain`
{\pagemark{} of \pageref{LastPage}}% for pagestyle `scrheading`
3. Section number in heading
To remove the section (or chapter-) number from the heading, in KOMAscript
you use the commands:
\renewcommand*{\sectionmarkformat}{}
and
\renewcommand*{\chaptermarkformat}{}
Unfortunately, this does not work in classicthesis
(the spaced smallcaps disappear). Instead, you have to use
\renewcommand{\sectionmark[1]{\markright{\spacedlowsmallcaps{#1}}}
4. Complete MWE
Your MWE with all your requirements implemented:
\documentclass[dottedtoc, headinclude, footinclude=true]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[pdfspacing]{classicthesis}
\usepackage{lastpage,lipsum,kantlipsum} % Generates dummy text.
\pagestyle{scrheadings} % <--- Affects the page header
% and page number in the footer.
\clearscrheadfoot
\ohead{\rightmark} % comment this line and uncomment the next
% to switch to `chapter name` in the heading
%\ohead{\leftmark} % comment out to
\cfoot[\pagemark]{\pagemark}
\cfoot[\pagemark{} of \pageref{LastPage}]% for pagestyle `scrplain`
{\pagemark{} of \pageref{LastPage}}% for pagestyle `scrheading`
\renewcommand{\sectionmark}[1]{\markright{\spacedlowsmallcaps{#1}}}
% Remove section number from heading
\begin{document}
\tableofcontents
\part{Liechtenstein}
\chapter{Liechtenstein}\kant[1-6]\clearpage
\part{Germany}
\chapter{Germany}\kant[1-3]\clearpage
\section{Bavaria}\kant[1-6]\clearpage
\section{Hesse}\kant[1-6]
\end{document}
Best Answer
The following should work for most document classes, although without the actual document class it is difficult to test.
You can selectively turn on the use of page numbers in the ToC using the following macros:
\gobbletocpage
and\restoretocpage
. The former redefines\addtocontents
, replacing\thepage
with\relax
(effectively doing nothing), while the latter restores this back to\thepage
.By means of example, the above ToC is void of page numbers after a call to
\gobbletocpage
(Section 1.3 and Chapter 2), and this is restored with\restoretocpage
.Since you have access to the
.cls
, replace your definition of\l@chapter
(and some surrounding code) with the following (lines 182-219):The above defines a new boolean "condition"
\ifchappagenum
that is set tofalse
(\chappagenumfalse
) by\gobbletocpage
andtrue
(\chappagenumtrue
) by\restoretocpage
. All of this is written to the.toc
file, since this is processed without any knowledge/before the rest of your document.Use
\gobbletocpage
before the chapter(s) that you want no page numbers for in the ToC, and\restoretocpage
before you want to restore the chapter page numbers. This condition can be modified and used to reformat chapter ToC entries as needed (not just page numbers). Here's youreasythesis.cls
with the above modifications used in a MWE: