0

I would like to create a Fancy Chapter Just like the one below: enter image description here

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

Thanks in Advance!

  • 1
    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 '21 at 09:10
  • 1
    Just a couple of links to start with: https://tex.stackexchange.com/q/403603/231952, https://texample.net/tikz/examples/fancy-chapter-headings/ – Ivan May 29 '21 at 10:18

2 Answers2

2

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}

enter image description here

mmencke
  • 156
  • 5
  • 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? – Sudarshan May 29 '21 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. – Sudarshan May 29 '21 at 14:01
  • Yes, also works with XeLaTeX. I have added a numberless version of the chapter titleformat – mmencke May 30 '21 at 13:06
  • i added my problem below @mmencke, could u help me sort it out? – Sudarshan May 31 '21 at 07:36
  • @Sudarshan see the \titleformat{name=\chapter,numberless}[display] I have added to the code. – mmencke May 31 '21 at 11:33
0

enter image description here

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}
{}
[]