11

I have a problem with section numbering in latex. I want to remove the section numbers from headings and contents but I want the numbers to be there for lemmas, theorems etc. I want it to look like:

 Section Whatever
   Some unimportant text.

 Section Whatever else
   Another unimportant text.
   Lemma 2.1
   Theorem 2.2 

 Section Whatever again
   Theorem 3.1

How can I do it? I tried

 \renewcommand\thesection{}

but it removes the numbers even from lemmas and theorems. Thank you very much :)

MattAllegro
  • 6,455
  • 5
  • 45
  • 52
Katarina
  • 111
  • 1
  • 1
  • 3

1 Answers1

21

Under the default article class we can merely remove the formatting applied to the section counter by adding

\makeatletter
\renewcommand{\@seccntformat}[1]{}
\makeatother

to the preamble. This will remove all sectional title numbering (\sections, \subsections, \subsubsections, ...), yet keep them where they are references or whenever \thesection is used.

enter image description here

\documentclass{article}

\newtheorem{theorem}{Theorem}[section]% Theorems numbered by section
\newtheorem{lemma}[theorem]{Lemma}% Lemma uses theorem's counter

\makeatletter
\renewcommand{\@seccntformat}[1]{}
\makeatother

\begin{document}

\section{Section whatever}
Some uninportant text.

\section{Section whatever else}
Another uninportant text.

\begin{lemma}
Some lemma.
\end{lemma}

\begin{theorem}
Some theorem.
\end{theorem}

\section{Section whatever again}
\begin{theorem}
Another theorem.
\end{theorem}

\end{document}
Werner
  • 14,324
  • 7
  • 55
  • 77
  • 2
    Hello :) That command removed the numbers from titles but they are still there in table of content. How can I fix that? – Katarina Jul 14 '16 at 07:59
  • 5
    @Katarina: You can add `\renewcommand{\numberline}[1]{}` to your preamble, which will remove all section numbering from the ToC. – Werner Jul 14 '16 at 18:59