I am trying to write a Preface with subsections, but without sectionnumbers (since the preface is technically not really part of the report). The sections and subsections are constructed using \titleformat like so:
\titleformat{\section}
{\normalfont\Large\bfseries\filcenter}
{\thesection.}{0.5em}{#1}
[\vspace{3pt}
{\color{\colorstyle}{\titlerule[1.5pt]}}
\vspace{1pt}
\titlerule]
\titlespacing*{\section}
{0em}{2em}{1em}
\titleformat{\subsection}
{\normalfont\bfseries\filcenter}
{}{0pt}
{\textcolor{\colorstyle}{\noindent\Vhrulefill}\hspace{1em}
\thesubsection.
\hspace{0.5em}#1\hspace{1em}\textcolor{\colorstyle}{\Vhrulefill}}
\titlespacing*{\subsection}
{0em}{2em}{0.5em}
However, \section* works fine and there is no number, but \subsection* are numbered as "0.0 subsectiontitle", but I don't want any numbering. Does anyone know why this happens and how to avoid it?
Working example:
\documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Style: Fonts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Style: Colors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[usenames,dvipsnames]{xcolor}
\newcommand{\colorstyle}[1]{\def\colorstyle{#1}}
\definecolor{mycolor}{RGB}{0,80,158}
\colorstyle{mycolor}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Style: Sections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[explicit,pagestyles]{titlesec}
\def\Vhrulefill{\leavevmode\leaders\hrule height 0.7ex depth \dimexpr0.4pt
0.7ex\hfill\kern0pt}
\titleformat{\section}
{\normalfont\Large\bfseries\filcenter}
{\thesection.}{0.5em}{#1}
[\vspace{3pt}
{\color{\colorstyle}{\titlerule[1.5pt]}}
\vspace{1pt}
\titlerule]
\titlespacing*{\section}
{0em}{2em}{1em}
\titleformat{\subsection}
{\normalfont\bfseries\filcenter}
{}{0pt}
{\textcolor{\colorstyle}{\noindent\Vhrulefill}\hspace{1em}
\thesubsection.
\hspace{0.5em}#1\hspace{1em}\textcolor{\colorstyle}{\Vhrulefill}}
\titlespacing*{\subsection}
{0em}{2em}{0.5em}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section*{Section without a number}
Bacon ipsum dolor sit amet pork loin leberkas turducken.
\subsection*{Subsection behaving oddly}
Beef pork belly porchetta turducken, bresaola venison boudin doner.
\end{document}
\thesubsection
command in the fifth argument to\titleformat
instead of in the third.\colorstyle
and\Vhrulefill
undefined.\documentclass{...}
and ending with\end{document}
.