4

enter image description hereI would like to make it so that the vertical space below the title of each chapter is the same when using the Bjornstrup package (i.e. so that the descenders do not affect the spacing - as shown by the red arrow in the picture below). I think I'm fairly happy with the spacing around "A chapter", so I'd really like titles without descenders (e.g. "Contents") to have the same vertical spacing as "A chapter" below the title. I would also like to remove the large "0" in the contents title. Any help appreciated, as always.

\documentclass[11pt,a4paper]{book}

% Packages[![enter image description here][1]][1]

\usepackage[left=3.5cm, right=3.5cm, top=4.3cm, bottom=4.25cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{MnSymbol}
\usepackage{xcolor}
\usepackage{scrextend}
\usepackage[calcwidth]{titlesec}
\usepackage{titleps}
\usepackage{microtype}
\usepackage[Bjornstrup]{fncychap} 
\usepackage{tikz}
\usepackage{lettrine}
\usepackage{enumitem}
\usepackage{type1cm} 
\usepackage{amsthm,thmtools}
\usepackage[framemethod=tikz,%
innerleftmargin=0pt
skipabove=0pt,
skipbelow=0pt,
innertopmargin=0pt,
innerrightmargin=0pt,
topline=false,
rightline=false,
bottomline=false,
topline=false,
leftline=false,
innerbottommargin=0pt]{mdframed}

\setlength{\parindent}{0.67cm}

% Section

% Fonts 

\protected\def\mathbb#1{\text{\usefont{U}{msb}{m}{n}#1}} 

% Header and Footer

% Chapter

\newcommand{\chapnumfont}{
  \usefont{T1}{pnc}{b}{n}
  \fontsize{100}{100}
  \selectfont
}

\renewcommand\DOCH{
  \settowidth{\py}{\CNoV\thechapter}
  \addtolength{\py}{0pt}
  \fboxsep=40pt
  \colorbox{chapbgcolor}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}
  \kern-\py\raise20pt
  \hbox{\color{chapnumcolor}\CNoV\thechapter}\\
}

\renewcommand\DOTI[1]{
  \nointerlineskip\raggedright
  \fboxsep=\myhi
  \vskip-1ex
  \colorbox{chapbgcolor}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak
  \vskip 40pt
}

\renewcommand\DOTIS[1]{
  \fboxsep=0pt
  \colorbox{chapbgcolor}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\
  \nointerlineskip\raggedright
  \fboxsep=\myhi
  \colorbox{chapbgcolor}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak
  \vskip 40pt
 }
\makeatother


\colorlet{chapbgcolor}{gray!75}
\colorlet{chapnumcolor}{black!60}

\newcommand{\chaptitle}[1]{
\begin{tikzpicture}
\fill[chapbgcolor!70,rounded corners=0pt] (0,2.3) rectangle (\linewidth,0);
\node[align=right,anchor=south east,inner sep=8pt,font=\huge\normalfont\bfseries] at (0.987\linewidth,0) {#1};
\node[font=\fontsize{60}{62}\usefont{OT1}{ptm}{m}{n}\selectfont\itshape\bfseries,text=chapnumcolor] at 
(0.975\linewidth,2.1) {\sloppy\thechapter};
\end{tikzpicture}
}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\sffamily}{}{25pt}{\chaptitle}
\titlespacing*{\chapter} {0pt}{-126pt}{33pt}

\setlength\headheight{15pt}

\begin{document}
\tableofcontents
\chapter{A chapter}
\mbox{}
\newpage
More text...
\newpage
Even more text...
\end{document}
1
+50

I would refrain from writing two different commands. If you ever want to adjust the appearance, you'll have to do it twice. TikZ has pgfkeys which allow you to switch the numbering on with a simple \tikzset{title number=true} and off with \tikzset{title number=false}. And to keep the distance the same, you only need to add an appropriate text depth.

\documentclass[11pt,a4paper]{book}

% Packages[![enter image description here][1]][1]

\usepackage[left=3.5cm, right=3.5cm, top=4.3cm, bottom=4.25cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{MnSymbol}
\usepackage{xcolor}
\usepackage{scrextend}
\usepackage[calcwidth]{titlesec}
\usepackage{titleps}
\usepackage{microtype}
\usepackage[Bjornstrup]{fncychap} 
\usepackage{tikz}
\usepackage{lettrine}
\usepackage{enumitem}
\usepackage{type1cm} 
%\usepackage{amsthm,thmtools} % see https://tex.stackexchange.com/a/41551/121799
\usepackage[framemethod=tikz,%
innerleftmargin=0pt
skipabove=0pt,
skipbelow=0pt,
innertopmargin=0pt,
innerrightmargin=0pt,
topline=false,
rightline=false,
bottomline=false,
topline=false,
leftline=false,
innerbottommargin=0pt]{mdframed}

\setlength{\parindent}{0.67cm}

% Section

% Fonts 

\protected\def\mathbb#1{\text{\usefont{U}{msb}{m}{n}#1}} 

% Header and Footer

% Chapter

\newcommand{\chapnumfont}{
  \usefont{T1}{pnc}{b}{n}
  \fontsize{100}{100}
  \selectfont
}

\renewcommand\DOCH{
  \settowidth{\py}{\CNoV\thechapter}
  \addtolength{\py}{0pt}
  \fboxsep=40pt
  \colorbox{chapbgcolor}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}
  \kern-\py\raise20pt
  \hbox{\color{chapnumcolor}\CNoV\thechapter}\\
}

\renewcommand\DOTI[1]{
  \nointerlineskip\raggedright
  \fboxsep=\myhi
  \vskip-1ex
  \colorbox{chapbgcolor}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak
  \vskip 40pt
}

\renewcommand\DOTIS[1]{
  \fboxsep=0pt
  \colorbox{chapbgcolor}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\
  \nointerlineskip\raggedright
  \fboxsep=\myhi
  \colorbox{chapbgcolor}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak
  \vskip 40pt
 }
\makeatother


\colorlet{chapbgcolor}{gray!75}
\colorlet{chapnumcolor}{black!60}

\newif\ifShowTitleNo
\tikzset{title number/.is if=ShowTitleNo} 
\tikzset{title number=false} 

\newcommand{\chaptitle}[1]{
\begin{tikzpicture}
\fill[chapbgcolor!70,rounded corners=0pt] (0,2.3) rectangle (\linewidth,0);
\node[align=right,text depth=0.25ex,anchor=south east,inner sep=8pt,font=\huge\normalfont\bfseries] at (0.987\linewidth,0) {#1};
\ifShowTitleNo
\node[font=\fontsize{60}{62}\usefont{OT1}{ptm}{m}{n}\selectfont\itshape\bfseries,text=chapnumcolor] at 
(0.975\linewidth,2.1) {\sloppy\thechapter};
\fi

\end{tikzpicture}
}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\sffamily}{}{25pt}{\chaptitle}
\titlespacing*{\chapter} {0pt}{-126pt}{33pt}

\setlength\headheight{15pt}

\begin{document}
\tableofcontents
\tikzset{title number=true}
\chapter{A chapter}
\mbox{}
\newpage
More text...
\newpage
Even more text...
\end{document}

enter image description here

enter image description here

5

It's not necessary to load fncychap (is it ever?), as you're completely redefining the chapter heading with titlesec.

The number can be get rid of by defining different styles for numbered and unnumbered chapters.

% openany to make a side by side picture
\documentclass[11pt,a4paper,openany]{book}

\usepackage{titlesec}
\usepackage{titleps}
\usepackage{tikz}

\newcommand{\chapnumfont}{%
  \fontsize{100}{100}\usefont{T1}{ptm}{b}{n}%
}

\colorlet{chapbgcolor}{gray!75}
\colorlet{chapnumcolor}{black!60}

\newcommand{\chaptitlenumbered}[1]{%
  \begin{tikzpicture}
  \fill[chapbgcolor!70,rounded corners=0pt] (0,2.3) rectangle (\linewidth,0);
  \node[
    align=right,
    anchor=south east,
    inner sep=8pt,
    font=\huge\normalfont\bfseries
  ] at (0.987\linewidth,0) {\strut#1};
  \node[
    align=right,
    font=\fontsize{60}{62}\usefont{OT1}{ptm}{b}{it},
    text=chapnumcolor
  ] at (0.975\linewidth,2.1) {\thechapter};
  \end{tikzpicture}%
}

\newcommand{\chaptitleunnumbered}[1]{%
  \begin{tikzpicture}
  \fill[chapbgcolor!70,rounded corners=0pt] (0,2.3) rectangle (\linewidth,0);
  \node[
    align=right,
    anchor=south east,
    inner sep=8pt,
    font=\huge\normalfont\bfseries
  ] at (0.987\linewidth,0) {\strut#1};
  \end{tikzpicture}%
}

\titleformat{name=\chapter}[display]
  {\normalfont\huge\bfseries\sffamily}
  {}
  {0pt}
  {\chaptitlenumbered}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\huge\bfseries\sffamily}
  {}
  {25pt}
  {\chaptitleunnumbered}
\titlespacing*{\chapter}
  {0pt}
  {-126pt}
  {33pt}

\setlength\headheight{15pt}

\begin{document}
\tableofcontents
\chapter{A chapter}
\mbox{}
\newpage
More text...
\newpage
Even more text...
\end{document}

enter image description here

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.