I am creating a booklet for a conference, using the documentclass scrbook
. The document is composed of different chapter
s: "About", "Timetable", "List of participants", etc. Each of these "chapters" starts on a new page (that can either odd or even).
I want my chapter
to render something like this (this is what I've managed so far based on this: http://texample.net/tikz/examples/fancy-chapter-headings/):
This is produced with the following MWE
\documentclass[openany]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage[explicit]{titlesec}
\usepackage{blindtext}
%--------------------------------
\titleformat
{\chapter} % command
{\bfseries\Huge} % format
{%
\thechapter
} % label
{0pt} % sep
{
\ifodd\value{page}{%
\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-3cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
\fill[orange] (0,0) rectangle (0.6\textwidth,1em);
\node[above, yshift=-0.2em, xshift=\textwidth] {#1};
\end{tikzpicture}
};
\end{tikzpicture}
}\else{%\
\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-3cm] at (current page.north east)
{\begin{tikzpicture}[remember picture, overlay]
\fill[orange] (0,0) rectangle (-0.5\paperwidth,1em);
\node[above, yshift=-0.2em, xshift=-\textwidth] (0,0) {#1};
\end{tikzpicture}
};
\end{tikzpicture}
}\fi%
} % before-code
[
\vspace{-3cm}
] % after-code
%------------------------------------------------
\begin{document}
\chapter*{About}
\blindtext[3]
\chapter*{Timetable}
\blindtext[3]
\end{document}
However, some points to improve:
the "Timetable" chapter is flushed left which is what I want, but the "About" is not compeltely flushed right. How can I do this?
for now the width of the orange bar is fixed to 0.5
\textwidth
. How can I make it adaptive, so that it goes from the border of the page up to the chapter name (the width depends on the chapter name)?
\node[yshift=-0.2em, xshift=0.6\textwidth,text width=0.4\textwidth,anchor=south west,draw] {#1\hfill{}};
? For the second question you first put the node and then draw the orange bar if there is space left