[Tex/LaTex] Removing the zero in the chapter numbering

chaptersnumberingtable of contents

I have a line of code to hide "Chapter" and just head every chapter in the format "ChapterNumber" + "." + "ChapterTitle".
However, the Table of Contents is assumed to be "Chapter 0", so it shows "0. Contents". Is there any way to hide this "0." so it shows "Contents" only?

Code used:

\documentclass[a4paper,12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\titleformat{\chapter}{}{}{0em}{\bf\LARGE\thechapter.~}

How the zero appears in the Contents table

Best Answer

Note that I used \bfseries instead of the long, long deprecated \bf and used \arabic{chapter} to format the number, you might also want to try \Roman{chapter} for example.

Update: second version (thanks to egreg)

As this answer is the checked one, I'll include egregs more correct one, which uses correctly the possibilities of \titleformat, which has 4 mandatory arguments:

\titleformat{<command>}{<format>}{<label>}{<sep>}{<before-code>}

  • <command> is the sectioning command you want to change, in your case \chapter.
  • <format> are text formatting commands to be applied, you want to use \bfseries\Large
  • <label> formats the label if the chapter is numbered, it is left out when not. You want \arabic{chapter}.~
  • <sep> is the hspace between <label> and the actual title, set it to {0pt}
  • <before-code> is arbitrary code that should be called before the title is typeset

So your version of \titleformat should be:

\titleformat{\chapter}{\bfseries\Large}{\arabic{chapter}.~}{0pt}{}

First Version, you should not use this:

You can check if \thechapter is greater than zero:

\documentclass[a4paper,12pt,twoside]{report}

\usepackage{titlesec}

\titleformat{\chapter}{}{}{0em}{\bfseries\LARGE\ifnum\value{chapter}>0\relax\arabic{chapter}.~\fi}

\begin{document}
\tableofcontents
\chapter{Test I}
\chapter{Test II}
\end{document}

Output: Table of contents:

Table of Contents

First Chapter with some blindtext:

Chapter 1