“Non-sciency” chapters and sections in a LaTeX book

One of my “customers” wanted a book that didn’t look so “sciency” (i.e., less like LaTeX). The first few tweaks (described in my last post) were more general, this one deals with the look of chapter and section headings.

I use the package titlesec for the task:

\usepackage{titlesec}

Each chapter should start on its own page. On top it will say “Teil X”, then a line, then the chapter name centered. At the bottom of the page a picture is included. This is the code for it:

\titleformat{\chapter} % command
[display] % shape: display, block, runin, hang (default)
{\bfseries\Large\itshape} % format
{\thechapter} % label
{0.5ex} % sep btw. label and title body
{\rule{\textwidth}{1pt} \vspace{1ex} \centering} % before-code
[{\vfill\includegraphics[width=\linewidth]{\Chapterimg}\pagebreak}] % after-code

The image for a chapter is set before each chapter with the custom-defined command Chapterimg:

\def\Chapterimg{img/chapterimage6}
\chapter{Einleitung}

A section is just the title in large bold font, no number in front of it:

\titleformat{\section} % command
[block] % shape
{\usekomafont{title}\large} % format
{}  % label
{0pt} % sep 
{} % before-code
[] % after-code

I also adjusted the spacing a bit:

\titlespacing{\section}{0pt}{1ex}{0pt} % less space for sections
\titlespacing{\subsection}{0pt}{0pt}{0pt} % subsection is like a paragraph

In a previous version of the book, the images were supposed to be placed next to the section headings. My attempt at doing that was to include the image in the “after-code” of the section format and add a bit of space at the right margin for it. It looked ok, but there were some issues with one-line vs. multi-line titles that I didn’t fix, because the images moved to the chapters instead.

[{\vspace{-3em}\hfill\includegraphics[width=4em]{\Chapterimg}\hspace{-5em}~}] % after-code
\titlespacing{\section}{0pt}{1ex}{0pt}[6em] % left margin / before / after / [right]