Here is an example without package titlesec
.
\documentclass[numbers=noenddot]{scrbook}[2015/10/03]
\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{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}}
\renewcommand\chapterformat{%
\raisebox{-6pt}{\colorbox{mybluei}{%
\parbox[b][60pt]{45pt}{\centering%
{\usekomafont{chaptername}{\chapapp}}%
\vfill{\usekomafont{chapternumber}{\thechapter\autodot}}%
\vspace{6pt}%
}}}\enskip}
\renewcommand\sectionformat{%
\setlength\fboxsep{5pt}%
\raisebox{-4pt}{\colorbox{mybluei}{%
\enskip\usekomafont{sectionnumber}{\thesection\autodot}\enskip}%
\quad%
}}
\renewcommand\subsectionformat{%
\setlength\fboxsep{5pt}%
\raisebox{-4pt}{\colorbox{mybluei}{%
\enskip\usekomafont{subsectionnumber}{\thesubsection\autodot}\enskip}%
\quad%
}}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
\makebox[0pt][l]{\rule[-5pt]{\textwidth}{1pt}}%
\@hangfrom{#3}{#4}%
}
\makeatother
\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\chapter{Chapter Title}
\section{Section Title}
\blindtext
\addsec{Unnumbered Section Title}
\blindtext
\subsection{Subsection Title}
\blindtext
\subsubsection{Subsubsection Title}
\blindtext
\blinddocument
\end{document}
Update because of updates in the question:
To get black chapter entries in the table of contents use
\addtokomafont{chapterentry}{\normalcolor}% entrys in tableofcontents not blue
If all subsections should be unnumbered use
\setcounter{secnumdepth}{\subsectionnumdepth}% subsubsection and lower unnumbered
And here is an example with lower rules:
\documentclass[numbers=noenddot]{scrbook}[2015/10/03]
\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}{\chapapp}}%
\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%
\ifstr{#3}{}{%
\rule[\dp\strutbox]{\textwidth}{1pt}}{%
\hspace*{50pt}\rule[\dp\strutbox]{\dimexpr\textwidth-50pt}{1pt}}%
}{}%
\ifstr{#1}{subsection}{%
\par\nobreak%
\ifstr{#3}{}{%
\rule[\dp\strutbox]{\textwidth}{1pt}}{%
\hspace*{70pt}\rule[\dp\strutbox]{\dimexpr\textwidth-70pt}{1pt}}%
}{}%
}
\makeatother
\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\chapter{Chapter Title}
\section{Section Title}
\blindtext
\addsec{Unnumbered Section Title}
\blindtext
\subsection{Subsection Title}
\blindtext
\subsubsection{Subsubsection Title}
\blindtext
\blinddocument
\end{document}
Update 2 because of a second update in the question
You are using a \parskip
so \par
inserts vertically space that must be removed:
\makeatletter
\renewcommand\sectionlinesformat[4]{%
\@hangfrom{\hspace*{#2}#3}{#4}%
\ifstr{#1}{section}{%
\parskip\z@% <- added, deactivates the parskip locally
\par\nobreak
\ifstr{#3}{}{%
\rule[\dp\strutbox]{\textwidth}{1pt}}{%
\hspace*{50pt}\rule[\dp\strutbox]{\dimexpr\textwidth-50pt}{1pt}}%
}{}%
\ifstr{#1}{subsection}{%
\parskip\z@% <- added, deactivates the parskip locally
\par\nobreak
\ifstr{#3}{}{%
\rule[\dp\strutbox]{\textwidth}{1pt}}{%
\hspace*{70pt}\rule[\dp\strutbox]{\dimexpr\textwidth-70pt}{1pt}}%
}{}%
}
\makeatother
Some additional remarks:
Do not set \parskip
manually! Use the KOMA-Script option parskip=half-
instead. There are other values for this option like half
, half+
, half*
and the same with full
. For further explanations see the scrguien.pdf (KOMA-Script documentation).
I would suggest to use package geometry
to set the page margins.
To get an entry for the lists and the bibliography in the table of contents use the KOMA-Script options listof=totoc
and bibilography=totoc
instead of \addcontentsline{toc}{chapter}{...}
.
You redefine \chapterformat
twice. Decide which one you want to use and remove the other.
The header of your new defined mychapterpagestyle
is outside the paper.
Here is suggestion redefining \chapterlineswithprefixformat
. This needs KOMA-Script version 3.19a or newer.
\documentclass[chapterprefix]{scrbook}[2015/10/03]
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{lmodern}
\RedeclareSectionCommand[
beforeskip=\dimexpr3.3\baselineskip+1\parskip\relax,
innerskip=0pt,% <- space between chapter number and chapter title
afterskip=1.725\baselineskip plus .115\baselineskip minus .192\baselineskip
]{chapter}
\renewcommand\raggedchapter{\raggedleft}
\renewcommand\chapterformat{{\fontsize{80pt}{80pt}\selectfont\textcolor{gray!25}{\thechapter}}}
\renewcommand\chapterlineswithprefixformat[3]{%
#2#3%
\vspace*{-.5\baselineskip}% <- adjust the space between the chapter and the rule here
\rule{\textwidth}{.4pt}\par\nobreak
}%
\RedeclareSectionCommands[
beforeskip=0pt plus 1ex minus .2ex,
afterskip=1sp plus .2ex
]{section,subsection}
\renewcommand*{\sectionformat}{\thesection\hspace*{1em}}
\renewcommand*{\subsectionformat}{\thesubsection\hspace*{1em}}
\setcounter{secnumdepth}{3}
\usepackage{blindtext}% for dummy text
\begin{document}
\tableofcontents
\blinddocument
\chapter{A long long long long long long long long long chapter title}
\Blindtext
\appendix
\blinddocument
\end{document}
Adjust beforeskip
, innerskip
and afterskip
for the sectioning commands to your needs.
Regarding a comment:
If there should be the same vertical white space between the top of the page and a chapter number or an unnumbered chapter, use a fixed length as beforeskip
for chapter
\RedeclareSectionCommand[
beforeskip=3.3\baselineskip,
...
]{chapter}
and insert some additional vertical space before the numbered chapter
\renewcommand\chapterlineswithprefixformat[3]{%
\ifstr{#2}{}{}{\vspace*{1ex}}% <- insert vertical space before numbered chapters
#2#3%
\vspace*{-.5\baselineskip}% <- adjust the space between the chapter and the rule here
\rule{\textwidth}{.4pt}\par\nobreak
}%
or remove some vertical space before unnumbered chapters
\renewcommand\raggedchapter{\raggedleft}
\renewcommand\chapterformat{{\fontsize{80pt}{80pt}\selectfont\textcolor{gray!25}{\thechapter}}}
\renewcommand\chapterlineswithprefixformat[3]{%
\ifstr{#2}{}{\vspace*{-1ex}}{}% <- remove vertical space before unnumbered chapters
#2#3%
\vspace*{-.5\baselineskip}% <- adjust the space between the chapter and the rule here
\rule{\textwidth}{.4pt}\par\nobreak
}%
Best Answer
Use
\titleformat
from packagetitlesec
to change the chapter font. For the lower levels you can use the stared version of this command.Note that you have to load
accanthis
beforepalatino
.If you only want to change the font settings for the section headings you could also use package
sectsty
insteadtitlesec
.But if you can use a KOMA-Script class it would be really easy: