I'm not very familiar to Latex. The numbering of my theorems, definitions, remarks etc. appears like for first definition. I don't want zeroes to appear if there are no subsections or subsubsections. Here is what Have in preamble



Please help.

Edit: In my first section (for example), there is no subsection, so I want numbering as 1.1, 1.2 and so on and not as, etc. In my second section I have a subsection but no subsubsection, there I want theorem numbering to be like "Theorem 2.1.1" and so on. I want four-digit numbering to start when there is a subsubsection". I hope my question is clear now.

  • 1
    lacking a clear idea of what you want, you may try to say \newtheorem{lemma}{Lemma}[section] and see if this is what you expect.
    – Denis
    Nov 22, 2022 at 6:11
  • Off-topic: Don't load xypic and hyperref twice. Nothing good will come out of such duplication.
    – Mico
    Nov 22, 2022 at 6:14
  • \newthorem{lemma}{Lemma}[section] gives a numbering which ignores subsection numbers. I want subsection and subsubsection numbers to be included in theorem numbering. The problem is that in my first section, I don't have any subsection, as a result my first definition gets numbered as "Definition" instead of only "Definition 1.1."
    – Ashraf
    Nov 22, 2022 at 7:23

1 Answer 1


I really would not encourage this way of doing. But quick and dirty you may try

My nice lemma
\subsection{The fist sub}
My nice second lemma
\subsubsection{The fist subsub}
My new lemma
My nice third lemma
\subsection{The second sub}
My nice fourth lemma

enter image description here

  • Although it may be a dirty way as you said , it partially worked for me. However, you didn't mentioned about subsection of a subsection i.e. subsubsection.
    – Ashraf
    Nov 22, 2022 at 9:53
  • see my edit. please consider accepting the answer if you think it is useful.
    – Denis
    Nov 22, 2022 at 9:58
  • Your edit has created some more problem. For example, in your "first sub" the numbering should restart from 1 i.e., Lemma 1.1.1 and not Lemma 1.1.2. Accordingly in "first subsub" it should appear as Lemma1.1.1.1 and not Lemma1.1.1.3.
    – Ashraf
    Nov 22, 2022 at 10:32
  • I guess what you want is unclear to me. Anyhow, you have now the nuts and bolts.
    – Denis
    Nov 22, 2022 at 10:37
  • Thanks to you. I managed to do what I wanted with sufficient hints from your answer. Im accepting it as answer.
    – Ashraf
    Nov 22, 2022 at 10:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .