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.~}
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 typesetSo your version of
\titleformat
should be:First Version, you should not use this:
You can check if
\thechapter
is greater than zero:Output: Table of contents:
First Chapter with some blindtext: