1

I am using scrreprt KOMA and have difficulties with compatibility. I had titlesec and fancyhdr but those are bad with KOMA as I know now. I changed fancyhdr for scrlayer-scrpage and have my headers and footers now like I want them. But when I implement them to my document I get difficulties with titlesec. Specifically the titleformat and titlespacing part. And I don't know if caption and booktabs is compatible too, but that's not as big an issue. I should have concentrated on other packages i guess, but now I am here. Maybe someone can help?

\documentclass[12pt, a4paper]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\setlength{\parindent}{0em} 
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{graphicx, epstopdf}
\usepackage{booktabs}
\usepackage{gensymb}
\usepackage{hyperref}
\usepackage[onehalfspacing]{setspace}
\usepackage{chemstyle}
\usepackage[labelfont=bf, textformat=period, textfont=singlespacing, justification=justified]{caption}
\usepackage[raggedright]{titlesec}
\usepackage{xcolor}
%\usepackage{fancyhdr}

\usepackage{lipsum}

\begin{document}

    \thispagestyle{empty}
    %\input{titlepage}

    \newpage 
    \thispagestyle{empty}
    \quad 
    \newpage
    \pagenumbering{Roman}

    \titlespacing*{\chapter} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\clearpage
\phantomsection
\addcontentsline{toc}{section}{Declaration of Authorship}
%\input{declaration}
\clearpage
\phantomsection
\addcontentsline{toc}{section}{Abstract}
%\input{abstract}
\clearpage
\phantomsection
\addcontentsline{toc}{section}{List of Abbreviations}
%\input{abbreviations}
\clearpage
\phantomsection
\addcontentsline{toc}{section}{\contentsname}
\tableofcontents
\clearpage
\phantomsection
\addcontentsline{toc}{section}{\listfigurename}
\listoffigures
\clearpage
\phantomsection
\addcontentsline{toc}{section}{\listschemename}
\listofschemes
\clearpage
\phantomsection
\addcontentsline{toc}{section}{\listtablename}
\listoftables
\clearpage
\pagenumbering{arabic}

\definecolor{ultramarineblue}{rgb}{0.25, 0.4, 0.96}
%\pagestyle{fancy} % Turn on the style
%\fancyhf{}
%\renewcommand{\headrule}{{\color{ultramarineblue}%
%       \hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}

%\renewcommand{\headrulewidth}{0.4pt} % optional
%\fancyhead[R]{\textsl{\leftmark}}
%\fancyfoot[R]{\vfootline\hspace{\linepagesep}\thepage}

%\fancypagestyle{plain}{%
%   \fancyhf{} % clear all header and footer fields
%   \fancyfoot[R]{\vfootline\hspace{\linepagesep}\thepage}
%   \renewcommand{\headrulewidth}{0pt}
%   \renewcommand{\footrulewidth}{0pt}}

%\newlength\linepagesep
%\setlength{\linepagesep}{5pt}
%\newcommand*\vfootline{\textcolor{ultramarineblue}{\rule[-2pt]{1pt}{2\ht\strutbox}}}

\titlespacing*{\chapter} {0pt}{50pt}{40pt}
\newcommand{\chapnumfont}{%     % define font for chapter number
    \usefont{T1}{pnc}{b}{n}%      % choose New Chancery, bold, normal shape
    \fontsize{130}{100}%          % font size 100pt, baselineskip 100pt
    \selectfont%                  % activate font
}
\colorlet{chapnumcol}{gray!75}  % color for chapter number

\titleformat{\chapter}[display]
{\filleft\bfseries}
{\filleft\chapnumfont\textcolor{chapnumcol}{\thechapter}}
{-24pt}
{\Huge}

\chapter{ChapterTitle}
   \lipsum
\section{SectionTitle}
   \lipsum
\end{document}

As mentioned the fancyhdr is not the problem. here's my solution.

\documentclass[12pt, a4paper,foot lines=2]{scrreprt}
\usepackage{lipsum}% only for dummy text
\usepackage{xcolor}
\definecolor{ultramarineblue}{rgb}{0.25, 0.4, 0.96}

\renewcommand\chaptermarkformat{\chaptername\ \thechapter\autodot\ \ }

\usepackage[automark,headsepline,markcase=upper]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\leftmark}
\rofoot*{\vfootline\hspace{\linepagesep}\pagemark}
\lefoot*{\pagemark\hspace{5pt}\vfootline}% for twosided document

\addtokomafont{headsepline}{\color{ultramarineblue}}

\newlength\linepagesep
\setlength{\linepagesep}{5pt}
\newcommand*\vfootline{{\usekomafont{headsepline}\rule[-2pt]{1pt}{2\ht\strutbox}}}

\begin{document}
\chapter{CTitle}
   \lipsum
\section{STitle}
   \lipsum
\end{document}
1
  • 1
    caption and booktabs can be used with KOMA.
    – cgnieder
    Commented Feb 5, 2018 at 17:13

1 Answer 1

4

Suggestion:

\documentclass[
  12pt,
  a4paper,% <- default
  listof=totoc,% <- added
  footlines=2,% <- typo fixed
  ngerman,english% <- moved
]{scrreprt}
\setuptoc{toc}{totoc}% <- added
\usepackage[utf8]{inputenc}
\usepackage{babel}% <-languages moved to the class options
\usepackage[T1]{fontenc}
\setlength{\parindent}{0em}% really? and no parskip option?
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{gensymb}

\usepackage[onehalfspacing]{setspace}
\usepackage{scrhack}% <- added before chemstyle
\usepackage{chemstyle}
\usepackage[labelfont=bf, textformat=period, textfont=singlespacing, justification=justified]{caption}


\usepackage{xpatch}% <- added

\usepackage{xcolor}
\definecolor{ultramarineblue}{rgb}{0.25, 0.4, 0.96}
\colorlet{chapnumcol}{gray!75}  % color for chapter number

\renewcommand\chaptermarkformat{\chaptername\ \thechapter\autodot\ \ }

\usepackage[automark,headsepline,markcase=upper]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\leftmark}
\rofoot*{\vfootline\hspace{\linepagesep}\pagemark}
\lefoot*{\pagemark\hspace{5pt}\vfootline}% for twosided document

\addtokomafont{headsepline}{\color{ultramarineblue}}

\newlength\linepagesep
\setlength{\linepagesep}{5pt}
\newcommand*\vfootline{{\usekomafont{headsepline}\rule[-2pt]{1pt}{2\ht\strutbox}}}


\RedeclareSectionCommand[
  beforeskip=-3.5ex plus -1ex minus -.2ex,
  afterskip=2.3ex plus .2ex,
  font=\rmfamily\Huge
]{chapter}

\let\originaladdchaptertocentry\addchaptertocentry
\xpatchcmd{\addchaptertocentry}{chapter}{section}{}{\PatchFailed}

\newcommand\startnumberedchapters{%
  \cleardoubleoddpage
  \pagenumbering{arabic}%
  \RedeclareSectionCommand[
    beforeskip=-100pt,
    afterskip=40pt
  ]{chapter}%
  \renewcommand*\chapterformat{{%
    \usefont{T1}{pnc}{b}{n}%      % choose New Chancery, bold, normal shape
    \fontsize{130}{100}%          % font size 100pt, baselineskip 100pt
    \selectfont
    \textcolor{chapnumcol}{\thechapter}%
  }}%
  \makeatletter
  \renewcommand*\chapterlinesformat[3]{%
    \ifstr{##1}{chapter}
    {\raggedleft##2\\##3\par}% changes for chapters
    {\@hangfrom{##2}##3}% original definition
  }%
  \makeatother
  \let\addchaptertocentry\originaladdchaptertocentry
}

\usepackage{lipsum}% <- only for dummy text
\usepackage{hyperref}% <- this package should be the last one
\begin{document}
\pagenumbering{roman}
\begin{titlepage}
\null \vfill
{\centering\Huge My Title\par}
\vspace{\stretch{3}}
\end{titlepage}
\clearpage\null\thispagestyle{empty}
\cleardoublepage
\pagenumbering{Roman}
\addchap{Declaration of Autorship}
\lipsum[1]
\addchap{Abstract}
\lipsum[2]
\addchap{List of Abbreviations}
\lipsum[3]
\tableofcontents
\listoffigures
\listofschemes
\listoftables

\startnumberedchapters
\chapter{ChapterTitle}
\lipsum[4-6]
\section{SectionTitle}
\lipsum[7-10]
\end{document}

Example pages:

enter image description here

enter image description here

1
  • Better put the languages as options to the class, too.
    – cfr
    Commented Feb 6, 2018 at 4:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .