5

How can I remove section numbers from the Table of Contents? My document class is article:

\documentclass[a4paper]{article}
\begin {document}
\tableofcontents
\section{one}
test text number one
\section{two}
test text number two
\end{document}

enter image description here

6
  • 2
    Have you tried doing this using tocloft? (Click on link for documentation) I think using that package and adding \renewcommand\numberline[1]{} does the trick.
    – yori
    Dec 19, 2014 at 8:47
  • It seems useful, but how can I use that in my problem? Dec 19, 2014 at 9:00
  • Can you give us a minimal working example?
    – Johannes_B
    Dec 19, 2014 at 9:01
  • Yes, of course! Dec 19, 2014 at 9:11
  • 1
    @SeyedAmirMousavian : Add \usepackage{tocloft} and then \renewcommand\numberline[1]{} ? Seems to work for me.
    – yori
    Dec 19, 2014 at 13:01

2 Answers 2

6

You can easily do that with the titlesec/titlestoc package. It has commands that allow for a different formatting of numbered and unnumbered sections (if you want to add unnumbered sections) in the table of contents:

\documentclass[a4paper]{article}
\usepackage{titletoc}

\begin {document}
\titlecontents{section}[0em]
{\vskip 0.5ex}%
{\scshape}% numbered sections formatting
{\itshape}% unnumbered sections formatting
{}%

\tableofcontents

\section{A First Section}
Test text number one. 

\section{Another Section}
Test text number two. 

\section*{An Unnumbered Section}
Test text number three. 
\addcontentsline{toc}{section}{An Unnumbered Section}
\end{document} 

enter image description here

6

Following Astrinus's advice, you can add the two lines of code between \makeatletter and \makeatother, given in egreg's answer, to modify the entry in the table of contents. Here is how you can do this:

\documentclass[12pt, a4paper]{article}

\makeatletter
\let\latexl@section\l@section
\def\l@section#1#2{\begingroup\let\numberline\@gobble\latexl@section{#1}{#2}\endgroup}
\makeatother

\begin{document}
\tableofcontents
\newpage
\section{One}
test text number one
\section{Two}
test text number two
\end{document}

Notice that you should insure a \newpage is there after the \tableofcontents

enter image description here

1
  • You forgot an opening curly brace, which resulted in an error when compiling. I fixed that. Jan 19, 2016 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.