Mitali - 3 months ago 13
LaTeX Question

# Remove section number but display the number in table of contents in LaTeX

I am new to LateX. I know how to remove the section number by using

\section*{heading}
\section{heading}
.
But when I display the section heading in the Table of Contents , it does not print the section number. I want the section number to be displayed before "Introduction to Project" and "Introduction to company" in the Table of Contents shown below.

The titlesec package is very useful to modify your chapter and section titles. An important command is \titleformat, which is described on page 4 of the manual. The command looks like this:

\titleformat{⟨command⟩}[⟨shape⟩]{⟨format⟩}{⟨label⟩}{⟨sep⟩}{⟨before-code⟩}[⟨after-code⟩]


here, we want to change the \section command, i.e. <command> is \section. The <shape> setting is optional - we'll just leave the default value. In <format>, we define how the title shall be formatted. The default for \section is \normalfont\Large\bfseries, so we'll set it to that. If you want to change the appearance, you can do that here. Now, the interesting part: the <label> is the section number - we don't want to print it, so we'll lave that field empty. The <sep> is the separation between label and title, which should be zero if we don't have a label. Finally, with <before-code> and <after-code> we can add any code which should be run before or after printing the title. We don't need that either. So, our command is:

\titleformat{\section}{\normalfont\Large\bfseries}{}{0pt}{}


Here, a demonstration of that:

\documentclass{article}

\usepackage{titlesec}
\titleformat{\section}{\normalfont\Large\bfseries}{}{0pt}{}

\begin{document}

\tableofcontents

\section{Introduction to Company}
This is the company.

\section{Introduction to Project}
My project is very nice.

\end{document}