# How to manage chapter title position with a background picture?

I wrote the following code in order to design a chapter title but there is two things I did not succeed to do.

\documentclass{book}

\title{Titre de la thèse}
\author{moi}
\date{\today}

\usepackage{lipsum}

\usepackage[top = 2cm, left = 2cm, right = 2cm, bottom = 2cm, head = 14pt, headsep = .5cm]{geometry}
\usepackage{tikz}
\def\docColor{blue}

\usepackage{titlesec}
\titleformat{\chapter}
{\color{white}\sffamily\Huge\bfseries}
{}{0pt}
{\begin{tikzpicture}[overlay, remember picture]
\fill[\docColor] (current page.north west) -- (current page.north east)
-- ++ (0, -6cm) -- ++ (-\paperwidth, -2cm)
node[pos=.5, fill=black!60, text=white, minimum width=6cm,
inner sep=3mm]
{\sffamily\textsc\chaptername~\thechapter}
-- cycle;
\end{tikzpicture}
}
\titlespacing*{\chapter}{0pt}{0cm}{4cm}

\begin{document}

\maketitle

\chapter{Un premier chapitre, Un premier chapitre, Un premier chapitre}

\lipsum[1-5]

\chapter{Un second chapitre, Un second chapitre, Un second chapitre}

\lipsum[1-5]

\end{document}


1) I would like to remove the indentation. As you can see, if the title span over two lines they are not left justified.

2) I would like to shift on the right the title in order to put a picture on the left side. I would like to do something like

\parbox[c]{.2\textwidth}{a picture}
\parbox[c]{.8\textwidth}{Chapter title}


Here's one possibility:

1. Simply comment out a spurious blank space after \end{tikzpicture}.

2. I used the explicit option for titlesec and then used two side-by-syde \nodes of predefined width; one for the image, the other one for #1 (the actual title).

3. I also defined a variant using numberless for starred chapters (such as the table of contents, the list of figures, etc).

\documentclass{book}
\usepackage[top = 2cm, left = 2cm, right = 2cm, bottom = 2cm, head = 14pt, headsep = .5cm]{geometry}
\usepackage[explicit]{titlesec}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{lipsum}

\def\docColor{blue}

\titleformat{\chapter}
{\color{white}\sffamily\Huge\bfseries}
{}{0pt}
{\begin{tikzpicture}[overlay, remember picture]
\fill[\docColor] (current page.north west) -- (current page.north east)
-- ++ (0, -6cm) -- ++ (-\paperwidth, -2cm)
node[pos=.5, fill=black!60, text=white, minimum width=6cm,
inner sep=3mm]
{\sffamily\textsc\chaptername~\thechapter}
-- cycle;
\node[text width=.2\textwidth,anchor=west]
(titleimage)
{\includegraphics[width=\linewidth]{example-image-a}};
\node[text width=.8\textwidth,anchor=west]
(title) at (titleimage.east)
{#1};
\end{tikzpicture}%
}
\titleformat{name=\chapter,numberless}
{\color{white}\sffamily\Huge\bfseries}
{}{0pt}
{\begin{tikzpicture}[overlay, remember picture]
\fill[\docColor] (current page.north west) -- (current page.north east)
-- ++ (0, -6cm) -- ++ (-\paperwidth, -2cm)
-- cycle;
\node[anchor=west,text width=\linewidth]
(title)
{#1};
\end{tikzpicture}%
}
\titlespacing*{\chapter}{0pt}{0cm}{5cm}

\title{Titre de la thèse}
\author{moi}
\date{\today}

\begin{document}

\tableofcontents

\chapter{Un premier chapitre, Un premier chapitre, Un premier chapitre}

\lipsum[1-5]

\chapter{Un second chapitre, Un second chapitre, Un second chapitre}

\lipsum[1-5]

\end{document}

• Nice, thank you ! Do you know why the \textsc does not work on \chaptername? – Ger Jul 10 '14 at 23:09
• @Ger You're welcome! Regarding your question, the problem is that the combination small caps + boldface + sans-serif is not available in all fonts (in fact, I can't remember off the top of my head a Type 1 font that allows this combination). You could try, for example, Utopia (through from the fourier package) that gives you small-caps+bold faced in the serif family. If you are using xelatex, perhaps you can find a font providing the desired combination. – Gonzalo Medina Jul 10 '14 at 23:46

With the explicit option of titlesec, it is easy:

\documentclass[french]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\title{Titre de la thèse}
\author{moi}
\date{\today}
\usepackage{babel}
\usepackage{lipsum}

\usepackage[top = 2cm, left = 2cm, right = 2cm, bottom = 2cm, head = 14pt, headsep = .5cm]{geometry}
\usepackage{tikz}
\def\docColor{blue}

\usepackage[explicit]{titlesec}
\titleformat{\chapter}
{\color{white}\setlength\parindent{0pt}\sffamily\Huge\bfseries}
{}{0pt}
{\begin{tikzpicture}[overlay, remember picture]
\fill[\docColor] (current page.north west) -- (current page.north east)
-- ++ (0, -6cm) -- ++ (-\paperwidth, -2cm)
node[pos=.5, fill=black!60, text=white, minimum width=6cm,
inner sep=3mm]
{\sffamily\textsc\chaptername~\thechapter}
-- cycle;
\end{tikzpicture}
\includegraphics[width =0.2\textwidth]{euclid-1945}%
\hfill \parbox[b]{.75\textwidth}{#1\\\mbox{}}}%
\titlespacing*{\chapter}{0pt}{0cm}{4cm}

\begin{document}

\maketitle

\chapter[Un premier chapitre]{ Un premier chapitre, Un premier chapitre, Un premier chapitre, Un premier chapitre}

\lipsum[1-5]

\chapter{Un second chapitre, Un second chapitre, Un second chapitre}

\lipsum[1-5]

\end{document}