1

Problem Description

I’d like to create a footer style that would be displayed on all pages except for the page, where there is \part title and its verso page (this exception is not a problem, as it works). So I added the following code into the preamble:

\clearscrheadfoot
\lefoot{\pagemark\quad\textsc{\headmark}}
\rofoot{\textsc{\headmark}\quad\pagemark}
\pagestyle{scrheadings}
\renewcommand*{\chapterpagestyle}{scrheadings}

The actual problem is that on every odd page, only the page number is displayed and no chapter title. There is no problem with the footer on even pages.

I’d like to note that I use xelatex and currently I am trying out the KOMA-Script.

Minimal Working Example

\documentclass[10pt, chapterprefix=false, twoside]{scrbook}

% Packages
\usepackage[a4paper, top=1in, bottom=1in, right=1in, left=1in, portrait]{geometry}
\usepackage{fontspec}            % For font definition
\usepackage{scrlayer-scrpage}    % For headers and footers (must be loaded before `titlesec`); also, in KomaScript, this is used instead of `titleps`
\usepackage{titlesec}            % For custom paragraph style of headings
\usepackage{lipsum}              % For Lorem Ipsum

% Global font family
\setmainfont{Libertinus Serif}
\setsansfont{Libertinus Sans}
\addtokomafont{disposition}{\rmfamily}

% Global paragraph and line settings
\setlength{\parindent}{0em}           % Set paragraph indentation
\setlength{\parskip}{0.08in}          % Paragraph spacing
\renewcommand{\baselinestretch}{1.0}  % Line \expandafter\selectlanguage\expandafter{\cvlang}

% Part title format
\titleformat{\part}{\Huge\scshape\bfseries\centering}{}{0em}{}%

% Chapter title format
\titleclass{\chapter}{straight}% For starting a chapter without page break

\titleformat{\chapter}[block]
    {\titlerule[1pt]\addvspace{0pt}\Large\scshape\bfseries\centering}
    {\thesection\enspace}{0pt}{}[\vspace{2pt}{\titlerule[1pt]}]
\titlespacing{\chapter}%
    {0mm}% How much of \titlerule line to remove from left
    {8mm}% Before \titlerule
    {0mm}% After \titlerule

\renewcommand*{\chaptermarkformat}{}% This is to get rid of the chapter number

% Headers and footers
\clearscrheadfoot
\lefoot{\pagemark\quad\textsc{\headmark}}
\rofoot{\textsc{\headmark}\quad\pagemark}
\pagestyle{scrheadings}
\renewcommand*{\chapterpagestyle}{scrheadings}

\begin{document}
    \part*{Test Part}

    \chapter*{Test Chapter or Whatever}%
    \chaptermark{Test Chapter}%

    \lipsum[1-14]

    \chapter*{Another Chapter to test}%
    \chaptermark{Another Chapter}%

    \lipsum[15-21]
\end{document}
  • 2
    Off-Topic: With KOMA-Script you should not change \parindent and \parskip manually but use either option parskip (with suitable value, e.g., parskip=half) or command \setparsizes. Also you should usually use \linespread or package setspace instead of redefining \baselineskip or just remove the "redefinition", because you redefine it to its default. – Schweinebacke Apr 27 at 7:53
  • I’ll look into this (and the titlesec ‘removal’) in a moment. – tukusejssirs Apr 27 at 7:59
2

Usually on one page is the chapter title shown, on the other page the section title in KOMA-Script.

To change this simply add

\automark[chapter]{chapter} % <============== usually \automark[section]{chapter}

in your preamble.

With the following complete code mwe.tex:

\documentclass[10pt, chapterprefix=false, twoside]{scrbook}

% Packages
\usepackage[a4paper, top=1in, bottom=1in, right=1in, left=1in, portrait]{geometry}
\usepackage{fontspec}            % For font definition
\usepackage{scrlayer-scrpage}    % For headers and footers (must be loaded before `titlesec`); also, in KomaScript, this is used instead of `titleps`
\usepackage{titlesec}            % For custom paragraph style of headings
\usepackage{lipsum}              % For Lorem Ipsum

% Global font family
\setmainfont{Libertinus Serif}
\setsansfont{Libertinus Sans}
\addtokomafont{disposition}{\rmfamily}

% Global paragraph and line settings
\setlength{\parindent}{0em}           % Set paragraph indentation
\setlength{\parskip}{0.08in}          % Paragraph spacing
\renewcommand{\baselinestretch}{1.0}  % Line \expandafter\selectlanguage\expandafter{\cvlang}

% Part title format
\titleformat{\part}{\Huge\scshape\bfseries\centering}{}{0em}{}%

% Chapter title format
\titleclass{\chapter}{straight}% For starting a chapter without page break

\titleformat{\chapter}[block]
    {\titlerule[1pt]\addvspace{0pt}\Large\scshape\bfseries\centering}
    {\thesection\enspace}{0pt}{}[\vspace{2pt}{\titlerule[1pt]}]
\titlespacing{\chapter}%
    {0mm}% How much of \titlerule line to remove from left
    {8mm}% Before \titlerule
    {0mm}% After \titlerule

\renewcommand*{\chaptermarkformat}{}% This is to get rid of the chapter number

% Headers and footers
\clearscrheadfoot
\automark[chapter]{chapter} % <=========================================
\lefoot{\pagemark\quad\textsc{\headmark}}
\rofoot{\textsc{\headmark}\quad\pagemark}
\pagestyle{scrheadings}
\renewcommand*{\chapterpagestyle}{scrheadings}

\begin{document}
    \part*{Test Part}

    \chapter*{Test Chapter or Whatever}%
    \chaptermark{Test Chapter}%

    \lipsum[1-14]

    \chapter*{Another Chapter to test}%
    \chaptermark{Another Chapter}%

    \lipsum[15-21]
\end{document}

you get the resulting pdf:

resulting pdf

Please note the warning you got in the mwe.log file:

Class scrbook Warning: Usage of package `titlesec' together
(scrbook)              with a KOMA-Script class is not recommended.
(scrbook)              I'd suggest to use the package only
(scrbook)              if you really need it, because it breaks several
(scrbook)              KOMA-Script features, i.e., option `headings' and
(scrbook)              the extended optional argument of the section
(scrbook)              commands.
(scrbook)              Nevertheless, using requested
(scrbook)              package `titlesec' on input line 10.
  • I noted the warning, read about it on bunch of sites, however, I was not able to reproduce the same thing with Koma-Script commands as with titlesec. The most basic thing I could not achive (yet) is to set a default font family (serif, sans and occassionally math) to Libertinus {Serif, Sans, Math}. At least, this works. :) Thank you. :) – tukusejssirs Apr 27 at 6:18
  • 2
    @tukusejssirs Setting of the default font is done by fontspec not titlesec and fontspec can be used with KOMA-Script in the same way as with, e.g., the standard classes. To setup a font for a sectioning command you can use \setkomafont/\addtokomafont or \RedeclareSectionCommand. If you have problems in setting up the chapter/section headings with KOMA-Script please ask another question (if no one of the already existing is suitable). – Schweinebacke Apr 27 at 7:30
  • Thank you, @Schweinebacke, for the info. … Anyway, back to answer: I added \renewcommand{\headfont}{\normalfont\scshape} to change the font style from italics to small-caps regular. – tukusejssirs Apr 27 at 7:42
2

You could also use \automark{chapter} and and replace \headmark by \leftmark. If more than one chapter starts on the same page the last chapter will set the mark for the footer even on odd pages.

\documentclass[10pt,
  headings=optiontohead% <- added
]{scrbook}
% Packages
\usepackage[margin=1in]{geometry}
\usepackage{fontspec}
\usepackage{scrlayer-scrpage}% sets page style scrheadings automatically
\usepackage{lipsum}% only for dummy text

% Global font family
\setmainfont{Libertinus Serif}
\setsansfont{Libertinus Sans}
\addtokomafont{disposition}{\rmfamily}

% Global paragraph and line settings
\setparsizes{0pt}{0.08in}{0pt plus 1fil}

% Part title format
\addtokomafont{disposition}{\rmfamily}
\addtokomafont{part}{\Huge\scshape}

% Chapter title format
\RedeclareSectionCommand[
  style=section,
  beforeskip=\dimexpr8mm-\parskip\relax,
  afterskip=-\parskip,
  indent=0pt,
  font=\Large\scshape,
  afterindent=false,
  runin=false
]{chapter}

\let\originalsectionlinesformat\sectionlinesformat
\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{chapter}
  {\parbox[b]{\textwidth}{%
    \titlerule\par%
    \centering #3#4\par\kern-.75\ht\strutbox
    \titlerule%
  }}
  {\originalsectionlinesformat{#1}{#2}{#3}{#4}}% original definition for other sectioning levels
}
\newcommand\titlerule[1][1pt]{\rule{\textwidth}{#1}}

% Headers and footers
\clearpairofpagestyles% <- replaces deprecated command
\automark{chapter}
\lefoot{\pagemark\quad\textsc{\leftmark}}
\rofoot{\textsc{\leftmark}\quad\pagemark}

\begin{document}
\addpart*{Test Part}

\addchap[Test Chapter]{Test Chapter or Whatever}
\lipsum[1-14]

\addchap[Another Chapter]{Another Chapter to test}
\lipsum[15-21]
\end{document}

Result:

screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.