14. Defining sectioning styles

A section in a document usually consists of a chapter title as well as first, second and third level headings. The titlesec package is used for this and then you define how each of the headings are formatted.

Note: For some of the long commands, I added line breaks for readability. You need to remove those breaks when using the syntax.

Using the titlesec package

To set sectioning styles and packages, you can use the titlesec package. titlesec pro­vid­es an in­ter­face for defining var­i­ous ti­tle styles.

1
\usepackage{titlesec}

Defining chapter titles

I configured the chapter title to have a 19pt font size.

1
\titleformat{\chapter}{\fontsize{19pt}{0em}\selectfont\bf}{\thechapter.}{1em}{}

To remove the large space above the chapter title:

1
\titlespacing*{\chapter}{0pt}{-30pt}{20pt}

To indent the section label:

1
\titlelabel{\llap{\makebox[1cm][l]{\thetitle}}\hspace*{25.4mm}}

To set the size and position of the chapter heading:

1
2
\titleformat{\chapter}{\fontsize{20pt}{0em}
  \selectfont\bf\color{namecolor}}{\thechapter.}{1em}{}

Defining section headings

To set the size and position of the section headings:

1
2
3
4
5
6
\titleformat{\section}[hang]
  {\normalfont\Large\bfseries\color{namecolor}}
  {\thesection.}
  {1em}{}

\titlespacing{\section}{0pt}{*4}{*1\.5}

For subsection headings:

1
2
3
\titleformat{\subsection}[hang]
  {\normalfont\Normalsize\bfseries\color{namecolor}}
  {\thesubsection.}{1em}{}

For subsubsection headings:

1
2
3
\titleformat{\subsubsection}[hang]
  {\normalfont\Normalsize\bfseries\color{namecolor}}
  {\thesubsubsection.}{1em}{}

Click to continue.