1

I'm using scrreprt for my class notes and changed the page layout to my likings. However firstly I would like to change the font of my page header to \mdseries to match the chapter prefix.

I'm also using the option headsepline, but want to remove the line between "Chapter prefix" and "Chapter name".

Any help would be appreciated.

M W E:

\documentclass[
    numbers=endperiod,
    toc=chapterentrydotfill,
    DIV=12
    ]
    {scrreprt}
    
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage[
  automark,
  autooneside=false,
  headsepline=true
    ]
    {scrlayer-scrpage}
    \pagestyle{scrheadings}
    \cohead{\Ifthispageodd{\rightmark}{\leftmark}}
    \cfoot*{\pagemark}
\usepackage{textcomp}

\let\raggedchapter\centering

\setkomafont{chapterprefix}{\normalsize\mdseries}
\KOMAoption{chapterprefix}{true}

\renewcommand{\chapterheadmidvskip}{%
    \par\nobreak\vskip -.1cm {\rule{\textwidth}{.5pt}}\par%
}
\RedeclareSectionCommand[beforeskip=0pt,afterskip=15pt]{chapter}
\usepackage{xpatch}
\tracingpatches
\xpatchcmd{\@@makeschapterhead}{%for the unnumbered
    \usekomafont{chapter}{#1}\par
}{%
    \usekomafont{chapter}{\MakeUppercase{#1}}\par
}{}{}
\xpatchcmd{\@@makechapterhead}{%for numbered
    \usekomafont{chapter}{#1}\par
}{%
    \usekomafont{chapter}{\MakeUppercase{#1}}\par
}{}{}
\renewcommand*{\chapterformat}{%
    \mbox{\huge\MakeUppercase{\chapappifchapterprefix{\nobreakspace}}\thechapter\autodot
    \IfUsePrefixLine{}{\enskip}}%
}

\renewcommand{\abstract}[1]{%
    \textbf{Abstract.} #1\par%
}

\usepackage{lipsum}


\begin{document}
    \tableofcontents
    \thispagestyle{empty}
    \setcounter{page}{0}
    
    \chapter{The Chapter Numbered One}
        \abstract{\lipsum[3]}
        
        \section{The Section Which Comes First}
            \lipsum
            
            \subsection{First Subsection}
                \lipsum
        
\end{document}
1
  • for the page header you can use \setkomafont{pageheadfoot}{\mdseries} . But beside this: I would avoid to patch internal commands like this. This is not reliable and actually your patches don't do nothing for me (with a current KOMA) as \@@makeschapterhead has changed there. – Ulrike Fischer Mar 29 at 11:45
1

If there should be no line between chapter prefix and chapter name, remove the redefinition of \chapterheadmidvskip. (Off topic: \chapterheadmidvskip should not be used to insert such a line.) The vertical space between chapter prefix and chapter name can be adjusted by option innerskip, eg.:

\RedeclareSectionCommand[beforeskip=0pt,afterskip=15pt,innerskip=7.5pt]{chapter}

If chapter prefix and chapter name should be uppercase, redefine \chapterlineswithprefixformat:

\renewcommand*{\chapterlineswithprefixformat}[3]{%
  \Ifstr{#1}{chapter}
    {\MakeUppercase{#2#3}}
    {#2#3}%
}

If chapter prefix should be \huge use

\setkomafont{chapterprefix}{\mdseries\huge}

If the page header should be upshape use either \addtokomafont{pagehead}{\upshape} or \addtokomafont{pageheadfoot}{\upshape}.

\documentclass[
  numbers=endperiod,
  toc=chapterentrydotfill,
  DIV=12
]{scrreprt}
\usepackage{lipsum}% only for dummy text

\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% only needed with outdated TeX distributions
\usepackage{csquotes}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{textcomp}

\usepackage[
  automark,
  autooneside=false,
  headsepline=true
]{scrlayer-scrpage}% sets page style scrheadinges automatically
\clearpairofpagestyles
\chead{\ifodd\value{page}\rightmark\else\leftmark\fi}
\cfoot*{\pagemark}
\addtokomafont{pageheadfoot}{\upshape}

\let\raggedchapter\centering
\setkomafont{chapterprefix}{\mdseries\huge}
\KOMAoption{chapterprefix}{true}

\RedeclareSectionCommand[beforeskip=0pt,afterskip=15pt,innerskip=7.5pt]{chapter}
\renewcommand*{\chapterlineswithprefixformat}[3]{%
  \Ifstr{#1}{chapter}
    {\MakeUppercase{#2#3}}
    {#2#3}%
}

\renewcommand{\abstract}[1]{%
    \textbf{Abstract.} #1\par%
}

\BeforeStartingTOC[toc]{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC[toc]{\clearpage}

\begin{document}
\pagenumbering{roman}
\tableofcontents

\cleardoubleoddpage
\pagenumbering{arabic}
\chapter{The Chapter Numbered One}
\abstract{\lipsum[3]}

\section{The Section Which Comes First}
\lipsum
\subsection{First Subsection}
\lipsum
\end{document}

enter image description here

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.