# Fancy Chapter Style - Custom

I would like to create a Fancy Chapter Just like the one below:

Could anyone help me out with this? (With the same Font for the headings and sections)

Thanks in Advance!

• Welcome to TeX.SX! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help.
– DG'
May 29, 2021 at 9:10
• Just a couple of links to start with: tex.stackexchange.com/q/403603/231952, texample.net/tikz/examples/fancy-chapter-headings
– Ivan
May 29, 2021 at 10:18

## 2 Answers

I have come somewhat close using the book class. The typesetting program is LuaLaTeX to be able to use the \fontsize{70}{60}\selectfontsuch that the chapter number is larger than \Huge. I have created a tcolorbox called titlecolorbox, which is just a black box with with text. I have used the explicit option for titlesec based on this answer. The documentation for the titlesec package can be found here, where the titleformat function is also explained. I hope this helps.

% !TEX TS-program = LuaLaTeX

\documentclass[12pt]{book}

\usepackage{geometry}

\usepackage{lipsum} %for dummy text
\usepackage{tcolorbox}
\newtcolorbox{titlecolorbox}[1]{ %the box around chapter
coltext=white,
colframe=black,
colback=black,
boxrule=0pt,
arc=0pt,
notitle,
width=4.8em,
height=2.4ex,
before=\hfill
}

\usepackage{xcolor}

\usepackage[explicit]{titlesec}
\titleformat{\chapter}[display]
{\sffamily\Huge}
{}
{0pt}
{\begin{titlecolorbox}{}
{\large\sffamily\MakeUppercase{\chaptername}}
\end{titlecolorbox}
\vspace*{-4.19ex}\noindent\rule{\textwidth}{0.4pt}
\parbox[b]{\dimexpr\textwidth-4.8em\relax}{\raggedright\MakeUppercase{#1}}{\hfill\fontsize{70}{60}\selectfont\thechapter}
}
[]

\titleformat{name=\chapter,numberless}[display]
{\sffamily\Huge}
{}
{0pt}
{\begin{titlecolorbox}{}
{\large\sffamily\MakeUppercase{\chaptername}}
\end{titlecolorbox}
\vspace*{-4.19ex}\noindent\rule{\textwidth}{0.4pt}
\parbox[b]{\dimexpr\textwidth-4.8em\relax}{\raggedright\MakeUppercase{#1}}
}
[]

\titleformat{\section}[display]
{\sffamily\large}
{}
{0pt}
{\hrule\vspace*{0.25ex}\parbox[b]{\dimexpr\textwidth\relax}{\textcolor{darkgray}{\thesection}\quad\raggedright\bfseries\MakeUppercase{#1}}}
[\hrule]

\begin{document}

\setcounter{chapter}{10}

\chapter{Modeling Event-Based Behaviour with State Machine}
\lipsum[3]
\section{Overview}
\lipsum[4]
\end{document}


• Since it works with LuaLaTeX, then, XeLaTeX also can get the compilation done? right? Since, I might have some plans to add some other language texts as well. Also, I tried Putting up the Table of contents, but that Chapter heading is getting appended to it as well (like the one you showed) Can that be rectified? May 29, 2021 at 13:50
• I guess, we might need to use a titleformat of table of contents as well, since the table of contents is also getting a chapter 0 as a count. May 29, 2021 at 14:01
• Yes, also works with XeLaTeX. I have added a numberless version of the chapter titleformat May 30, 2021 at 13:06
• i added my problem below @mmencke, could u help me sort it out? May 31, 2021 at 7:36
• @Sudarshan see the \titleformat{name=\chapter,numberless}[display] I have added to the code. May 31, 2021 at 11:33

I am getting this when I called the \tableofcontents command. I tried using this code below but didn't work:

    \titleformat{\tableofcontents}[display]
{\sffamily\Huge}
{}
[]