[Tex/LaTex] Section title disappears when using titlesec

titlesec

I'm writing a paper in LaTeX, and I wanted to use titlesec for custom title styling, when I tried to apply my custom styling to my chapter title, it worked.

However, when I tried to apply custom styling to my section, the section-title disappeared like in the following picture:

This is the code in my header:

\documentclass[a4paper,12pt,oneside]{book}
%header information
\usepackage{blindtext, array, color}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\usepackage[explicit]{titlesec}

\titleformat{\chapter}[block]{\Huge\bfseries}{\color{gray75}\thechapter}{20pt}{\begin{tabular}[t]{@{\color{gray75}\vrule width 2pt}>{\hsp}l}#1\end{tabular}}

\titleformat{\section}[block]
{\Large\bfseries}{\color{gray75}\thesection}{12pt}{}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage[style=ieee,backend=bibtex]{biblatex}
\usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm]{geometry}
\usepackage{setspace}
\usepackage{fancyhdr} 
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\cfoot{\thepage}
\pagestyle{fancy} 
\setstretch{1.3}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}
\newcommand{\abbrlabel}[1]{\makebox[3cm][l]{\textbf{#1}}}
\newenvironment{abbreviations}{\begin{list}{}{\renewcommand{\makelabel}{\abbrlabel}}}{\end{list}}
\addbibresource{references.bib}

\begin{document}

I don't understand what is happening!

Best Answer

Since you're using explicit, the code for the section should be

\titleformat{\section}[block]
{\Large\bfseries}{\color{gray75}\thesection}{12pt}{#1}

However, I usually prefer not using the option: it's easier if you define a suitable one argument macro and keep the code in a different place, reducing clutter.

\documentclass[a4paper,12pt,oneside]{book}

\usepackage{color}
\usepackage{array}
\usepackage{titlesec}

\definecolor{gray75}{gray}{0.75}

\titleformat{\chapter}[block]
  {\Huge\bfseries}
  {\color{gray75}\thechapter}
  {20pt}
  {\formatchapter}

\titleformat{\section}[block]
  {\Large\bfseries}
  {\color{gray75}\thesection}{12pt}
  {}

\newcommand{\formatchapter}[1]{%
  \begin{tabular}[t]{@{\color{gray75}\vrule width 2pt}>{\hspace{20pt}}l}
  #1
  \end{tabular}%
}

\begin{document}

\chapter{State of the art}

\section{First section}

\end{document}

enter image description here