2

How can I make a horizontal rule below the top header (where the current chapter page or section is written)? And last but not least on the even pages in the header it is written

  1. Chapter title

but I would like it to have

Chapter 1. Chapter title

Is this possible?

My code is the following:

\documentclass[a4paper,twoside,12pt,chapterprefix=false,listof=totoc,bibliography=totoc]{scrbook}

    \usepackage[english]{babel}
    \usepackage{blindtext}
    \usepackage{amsmath,amssymb,amsthm}
    \usepackage{longtable}
    \usepackage[font={small,sl},hang,labelfont=bf]{caption}
    \usepackage{booktabs}

    \ifpdfoutput{%
        \usepackage{graphicx}
        \usepackage[]{pdfpages}
    }{%
        \usepackage{graphicx}
    }
    \usepackage{rotating}

    \usepackage{scrlayer-scrpage}
    \KOMAoptions{headinclude}

    % **** Defining chapter style start ****

    \usepackage[T1]{fontenc}
    \usepackage{xcolor}
    \usepackage{charter}

    \definecolor{mybluei}{RGB}{28,138,207}
    \definecolor{myblueii}{RGB}{131,197,231}

    \addtokomafont{disposition}{\usefont{T1}{qhv}{b}{n}\selectfont\color{myblueii}}

    \addtokomafont{chapter}{\fontsize{30pt}{30pt}\selectfont}
    \newkomafont{chapternumber}{\fontsize{50}{120}\selectfont\color{white}}
    \newkomafont{chaptername}{\itshape\rmfamily\small\color{white}}
    \addtokomafont{chapterentry}{\normalcolor}% entrys in tableofcontents not blue

    \addtokomafont{section}{\fontsize{14pt}{14pt}\selectfont}
    \newkomafont{sectionnumber}{\fontsize{18pt}{18pt}\selectfont\rmfamily\color{white}}

    \addtokomafont{subsection}{\fontsize{12pt}{12pt}\selectfont}
    \newkomafont{subsectionnumber}{\fontsize{16pt}{16pt}\selectfont\rmfamily\color{white}}

    \setcounter{secnumdepth}{\subsectionnumdepth}% subsubsection and lower unnumbered

    \renewcommand\chapterformat{%
      \raisebox{-6pt}{\colorbox{mybluei}{%
          \parbox[b][60pt]{45pt}{\centering%
            {\usekomafont{chaptername}{\chaptername}}%
            \vfill{\usekomafont{chapternumber}{\thechapter\autodot}}%
            \vspace{6pt}%
          }}}\enskip}

    \renewcommand\sectionformat{%
      \setlength\fboxsep{5pt}%
      \colorbox{mybluei}{%
          \parbox{40pt}{\centering\usekomafont{sectionnumber}{\thesection\autodot}}}%
        \quad%
      }

    \renewcommand\subsectionformat{%
      \setlength\fboxsep{5pt}%
      \colorbox{mybluei}{%
        \parbox{60pt}{\centering\usekomafont{subsectionnumber}{\thesubsection\autodot}}}%
    \quad%
    }

    \makeatletter
    \renewcommand\sectionlinesformat[4]{%
      \@hangfrom{\hspace*{#2}#3}{#4}%
      \ifstr{#1}{section}{%
        \par\nobreak\vspace*{-\parskip}% <- changed
        \ifstr{#3}{}{%
          \rule[\dp\strutbox]{\textwidth}{1pt}}{%
          \hspace*{50pt}\rule[\dp\strutbox]{\dimexpr\textwidth-50pt}{1pt}}%
      }{}%
      \ifstr{#1}{subsection}{%
        \par\nobreak\vspace*{-\parskip}% <- changed
        \ifstr{#3}{}{%
          \rule[\dp\strutbox]{\textwidth}{1pt}}{%
          \hspace*{70pt}\rule[\dp\strutbox]{\dimexpr\textwidth-70pt}{1pt}}%
      }{}%
    }
    \makeatother

    % **** Defining chapter style end ****

    \usepackage{times}
    \usepackage{helvet}
    \usepackage[T1]{fontenc}

    \ifpdfoutput{%
        \usepackage[pdftex,
            bookmarks,
            bookmarksopen=true,
            bookmarksnumbered=true,
            pdfauthor={Rafael Wampfler},
            pdftitle={Engagement Detector: Modelling engagement dynamics in virtual environments},
            pdfsubject={The report of the master thesis about the modelling engagement dynamics in virtual environments.},
            pdfkeywords={machine learning, engagement dynamics, classification, virtual environments, calcularis, learning, minecraft},
            colorlinks=false,
            linkcolor=black,
            citecolor=black,
            filecolor=black,
            urlcolor=black,
            anchorcolor=black,
            menucolor=black,
            breaklinks=true,
            pageanchor=true,
            plainpages=false,
            linkbordercolor=red,
            citebordercolor=red,
            urlbordercolor=red,
            pdfpagelabels=true]{hyperref}
    }{}

    \ifpdfoutput{%
        \pdfcompresslevel=9
        \DeclareGraphicsExtensions{.pdf,.png}
    }{}

    \bibliographystyle{alpha}

    \topmargin -0.5in
    \textheight 9.3in
    \textwidth 6.3in
    \oddsidemargin 0.18in
    \evensidemargin -0.22in
    \parskip 0.1in
    \parindent 0in

    \renewcommand{\arraystretch}{1.5}
    \renewcommand{\baselinestretch}{1}

    \begin{document}

    \hypersetup{pageanchor=false}

    \hypersetup{pageanchor=true}
    \pagenumbering{roman}
    \setcounter{page}{1}

    %\include{abstract}

    %\include{acknowledgment}

    \tableofcontents

    \listoffigures

    \listoftables

    \pagenumbering{arabic}

    % ---- MAIN PART ----

      \chapter{Chapter Title}
      \section{Section Title}
      \blindtext
      \addsec{Unnumbered Section Title}
      \blindtext
      \subsection{Subsection Title}
      \blindtext
      \subsubsection{Subsubsection Title}
      \blindtext
      \blinddocument

    % ---- END MAIN PART ----

    \appendix
    \clearpage

    %\include{appendix}

    \clearpage
    \renewcommand*{\chapterpagestyle}{empty}

    \bibliography{references}

    \end{document}
6
  • 2
    Much of your code doesn't seem to be relevant to the question you're asking here. Could you lessen your example to only the code required to show the header? You can have a look at this guide for how to prune your code for this purpose. Jan 27 '16 at 23:17
  • Isn't that the effect of chapterprefix=false? Check the documentation - I don't remember, but it sounds suspicious.
    – cfr
    Jan 28 '16 at 0:01
  • @cfr With chapterprefix or chapterprefix=true there is also a prefix line fo the chapter title in the document. AFAIK the OP does not want a two line chapter title..
    – esdd
    Jan 28 '16 at 0:25
  • @esdd Oh, I see. You may be right. I guess it seems odd to me to want it in the header and not in the title of the chapter, but that would make sense of the question.
    – cfr
    Jan 28 '16 at 0:53
  • @cfr It is following up tex.stackexchange.com/q/288737/43317
    – esdd
    Jan 28 '16 at 0:58
3

To get a sepline below the header on pages using page style scrheadings use option headsepline.

\usepackage[headsepline]{scrlayer-scrpage}

If the chapter prefix should be in the page header and there should be a prefix line before the chapter title you could use the option chapterprefix or one of the aliases twolinechapter, chapterwithprefix, chapterwithprefixline.

AFAIK you do not want a two line chapter title with the prefix in the first line. Then you have to change the apperance of the chapter number in the page header redefining \chaptermarkformat:

\renewcommand*\chaptermarkformat{\chapapp\ \thechapter\autodot\enskip}

enter image description here

\documentclass[12pt]{scrbook}

\usepackage[english]{babel}
\usepackage{blindtext}% dummy text

\usepackage[headsepline]{scrlayer-scrpage}
\renewcommand*\chaptermarkformat{\chapapp\ \thechapter\autodot\enskip}

\begin{document}
\blinddocument
\blinddocument
\end{document}
0

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.