[Tex/LaTex] \titleformat is causing the section title to appear twice in Table of Contents

sectioningtable of contentstitlesec

Here is how it shows:

image

The section appears twice. Ideally I'd like it to be

  1. BACKGROUND AND RATIONALE

with that dot and no bold.

Here is the \titleformat that is causing this behavior:

\titleformat{\section}%
[hang]% <shape>
{\clearpage\centering\bfseries\fontsize{14pt}{14}\selectfont}% <format>
{\thesection.\quad}% <label>
{0pt}% <sep>
{}% <before code>

Best Answer

The double entry is caused by \clearpage. However, \titlesec has no effect on the the table of contents typesetting, so you should be more explicit about your setup.

For the moment here's how you can get an automatic \clearpage at \section without affecting the table of contents.

\documentclass{article}
\usepackage{titlesec}

\titleformat{\section}[hang]% <shape>
  {\centering\bfseries\fontsize{14pt}{14}\selectfont}% <format>
  {\thesection.\quad}% <label>
  {0pt}% <sep>
  {}
\usepackage{etoolbox}
\preto\section{\clearpage}

\begin{document}
\tableofcontents
\section{Background and rationale}
\end{document}
Related Question