'\tableofcontents and titlesec package interaction

I use titlesec package, and \tableofcontents for TOC.

Problem: TOC header 'Contents' is on same line as the first section.

Beneath a minimal working example:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[tiny, compact]{titlesec}
\titleformat{\section}[runin]
  {\normalfont\normalsize\bfseries}
  {\thesection.}
  {5pt}
  {}[.]

\begin{document}
\tableofcontents
\section{Introduction}
Test.
\end{document}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source