I'm working on my chapter titles. I like them to have a background which stretches to the edge of the page.
The drawbacks of the minimal document below are:
- The TOC also has the background, too. I'd rather have the TOC text color in the red background color I used for fill and have no background fill at all in the TOC. Eventually the default black would work, too (but red would be cooler, including the TOC page numbers).
- I need to move the
\rule
I used a fair bit down since a bit of padding there looks better (and have background for letters like p, q, g, etc.) - I'm not sure it works well with multiple line titles, but that could probably be puzzled out with enough padding and increasing the size of
\rule
.
\documentclass[12pt,a4paper,
% Add lists to TOC
listof=numbered,numbers=noenddot,version=first,
]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\inputencoding{utf8}
\usepackage{helvet}
\usepackage{mathpazo}
\usepackage{setspace, lipsum}
\usepackage{xcolor}
\usepackage{tocloft}
% SECTION TITLES
% apply only singlespace to section starters (chapters, etc.)
% can also be set only for `chapter` instead of sectioning
\makeatletter
\addtokomafont{sectioning}
{\color[RGB]{255,255,255}
\makebox[0pt][l]{{\color[RGB]{212,17,37}\rule{1.3\textwidth}{2em}}}
}
{\setstretch{\setspace@singlespace}
}
\makeatother
\begin{document}
% TOC
\tableofcontents
\pagebreak
\chapter{Introduction}
\lipsum[1]
\chapter{Main Part}
\lipsum[2]
\chapter{Conclusion}
\lipsum[3]
\end{document}
I also saw this similar thread, but I'm \blap
and \tlap
might not be capable of adjusting well to multi-line chapter titles.
Then again, I'm positive there's a better way to do what I want than my current approach, maybe even a \colorbox
. But my head is hurting from the LaTeX input of the last days and I figured for this tricky problem some professional help might be beneficial.
Does anyone know how to pull it off?
Status: LaTeX user for 3 days.