4

I am trying to write a LaTeX report (using class report) but I don't want to use chapters, only sections, subsections and subsub. Using

\renewcommand{\thesection}{\arabic{section}},

my sections numbering now start at 1 and not 0.1, which is what I wanted. However, my table of contents keep the 0 before the 1 (eg 0.1 "Title") meant for the chapter numbering. How can I remove it ?

I know that the class article doesn't have chapters and could be a solution but is there a way to remove those 0 before the 1 in the table of contents without using the article class ?

Thanks for your answers

edit : this is what I did :

\documentclass[a4paper]{report}

\begin{document}
\renewcommand{\thechapter}{}%
\renewcommand{\thesection}{\arabic{section}}

\setcounter{tocdepth}{3} %I want the subsubsection in my ToC
\tableofcontents

\section*{Introduction}
\section{first section}

\appendix
\addcontentsline{toc}{section}{Annexes} % I want the appendix title in my ToC
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\section*{Annexes}

\renewcommand{\thesubsection}{\Alph{subsection}} % And the numbering with letters
\subsection{first appendix}

\end{document}
  • Welcome to TeX.SX! Although the question is quite clear, it's better to provide some small sample document to work with. – user31729 May 8 '15 at 11:36
  • I'm not sure why you want to use the report class; is there any particular reason? However, I get just the section number in the TOC, in my experiment. Can you add a minimal example? – egreg May 8 '15 at 11:51
  • no particular reason for the report class, I just thought it was better suited for an internship report – etienne May 8 '15 at 11:52
  • 2
    I think you simply forgot to compile it twice, since it works the way you want without adding \renewcommand{\thechapter}{} – Sterry May 8 '15 at 12:10
  • 1
    @etienne: LaTeX can't know in advance how many sections etc. there would be. The first run stores the information, the second run uses this information to typeset the table of contents. If you have a book without toc you have to look for the chapters/sections too and count them yourself before you know the number ;-) – user31729 May 8 '15 at 12:12
4

This should work for most cases:

Edit Meanwhile there is a MWE by the OP. Probably, the OP forgot to compile twice.

\documentclass{report}


\renewcommand{\thesection}{\arabic{section}}



\begin{document}
\tableofcontents
\section{First} \label{firstsection}
\subsection{First section} \label{firstsubsection}

\end{document}
  • In general, article class would be easier, in this case – user31729 May 8 '15 at 11:45
  • 3
    I get no 0 even without redefining \thechapter – egreg May 8 '15 at 11:55
  • @egreg: Right, it's not necessary at all. I believe, I changed the 'mwe' by the OP somehow, probably between the first and 2nd run. – user31729 May 8 '15 at 11:57

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.