1

I tried to adapt @Bernard solution to my case, but I am facing some troubles. It is possible that I just simply don't understand the code, but I tried to change almost every parameters, and I can't solve it

Here is a MWE, well not so minimal, but adapted to what I need :

\documentclass[12pt]{report}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[top=2cm, bottom=2cm, left=1.5cm, right=1.5cm, headheight=15pt]{geometry}
\usepackage{microtype}
\usepackage[x11names]{xcolor}
\usepackage[sfdefault]{roboto}
\usepackage{tabularx}
\usepackage{colortbl}
\usepackage[pagestyles]{titlesec}%
\usepackage{lipsum}
\usepackage{setspace}

%%%%%%%%%%%%%%%

\newpagestyle{fancy}[\small\scshape]{\headrule
\sethead{The nice header}{}{\chaptertitle}
\setfoot{}{}{\usepage}
}

\colorlet{titlecolour}{Aquamarine3}
\newlength\labelframewd
\settowidth{\labelframewd}{\lsstyle\scshape\small\MakeLowercase{\chaptername}}

\newsavebox\chaplabelbox%

\newcommand\chaplabel{\color{titlecolour}%
\begin{tabularx}{\linewidth}{c@{\enspace}X}
    \cellcolor{titlecolour}\raisebox{-1ex}[2ex][7ex]{\hspace{1cm}} & \vskip-5.3mm\titlerule[2pt]
    \end{tabularx}
    }%

\titleformat{\chapter}[display]{\flushleft}
{\setlength{\tabcolsep}{0pt} \smash{\chaplabel}}%
{1ex} %position titre
{\thispagestyle{fancy}\vskip-11ex\hskip\labelframewd\fontsize{28}{32}\selectfont\bfseries}%

\titlespacing{\chapter}{0pt}{*0}{1\baselineskip}
\renewcommand\thechapter{\arabic{chapter}}

\titleformat{name=\chapter,numberless}[display]{\flushleft}
{\setlength{\tabcolsep}{0pt} \smash{\chaplabel}}%
{1ex} %position titre
{\thispagestyle{fancy}\vskip-11ex\hskip\labelframewd\fontsize{28}{32}\selectfont\bfseries}%

%%%%%%%%%%%%%%%

\begin{document}
\begin{spacing}{1.5}
\pagestyle{fancy}
\chapter{Nice Chapter}
\lipsum[0-2]
\newpage
\lipsum[0-2]
\end{spacing}
\end{document}

The output :

enter image description here

EDIT : I did not had problems when I used the chapterstyle as it was. It's when I tried to change the blue(green?) box size that it appeared.

  • try to replace \titlespacing{\chapter}{0pt}{*0}{1\baselineskip} with something like \titlespacing{\chapter}{0pt}{2\baselineskip}{1\baselineskip} – touhami May 26 '16 at 17:43
  • It's only worse ! It add more space between the chapter and the header – Paul Giroud May 27 '16 at 7:36
  • i will try to add an answer later – touhami May 27 '16 at 9:35
  • I identified one problem, it comes from the {c@{\enspace}X}. If I replace with {c@{\vspace{y}}X}, I can control (with y) the spacing between header and chapter head, but I lose the spacing between the ruler and the box – Paul Giroud May 27 '16 at 10:20
  • SOLVED : {c@{\vspace{1.5cm}\enspace}X} and I get to control the spacing by modifying the vspace ! – Paul Giroud May 27 '16 at 10:22
0

NB : Adding of the solution found 2 years ago but only posted in comments (as I could not give answer to my own questions then) SOLVED IT : {c@{\vspace{1.5cm}\enspace}X} and I get to control the spacing by modifying the vspace !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.