[Tex/LaTex] titlesec: different formats for numbered and unnumbered sections/chapters

titlesec

I'm not sure if this is too minimal. (In the real document the problem appears at the bibliography, table of contents and \chapter*)

\documentclass[a4paper, 11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[left=2cm,right=2cm,top=3cm,bottom=3cm]{geometry}

\usepackage{titlesec}
\titleformat{\chapter}[display]{\normalfont\bfseries}{}{0pt}{\LARGE\thechapter\quad}

\begin{document}
\chapter*{Not numbered}
\chapter{Numbered}
\end{document}

How do I get the \thechapter\quad to not apply for unnumbered chapters?

Best Answer

As far as I understand what you want to do, you should use the blockstyle. Add something like this to your preamble:

\usepackage[explicit]{titlesec}
\titleformat{name=\chapter,numberless}[block]{\normalfont\LARGE\bfseries}{}{0pt}{\addcontentsline{toc}{chapter}{#1}#1}

Also, replace your present code for numbered chapters with

\titleformat{\chapter}[block]{\normalfont\LARGE\bfseries}{\thechapter}{1em}{#1}
Related Question