1

My thesis has several chapters, and a few of them have sections and subsections. However, for the chapters that do not have sections, the theorem counter continues to label them "X.0.1, X.0.2" etc... how do I get rid of these "middle zeros"? I would like to keep the rest of the numbering the same, for instance,

Chapter 1

Section

Definition 1.1.1

Theorem 1.1.2

etc.

--

Chapter 2

Definition 2.1

Theorem 2.2

etc.

1
  • 1
    Welcome! Can you provide some code people can compile to reproduce the problem? This should be a complete but minimal document with just enough preamble and content to demonstrate the issue. Without knowing the code which typesets your theorems, we can't tell you how to modify it.
    – cfr
    Commented Apr 10 at 4:44

1 Answer 1

1

There are two options (you probably are in favor of the second one):

A: keeping the 3 digits for numbering but setting 0 to 1:

Due to the missing subsection the LaTeX counter subsection is not increased by 1. But you can do this manually: e.g., after the \section{...} command just add

\addtocounter{subsection}{1}

and the respective counter's value was increase as it would have been if you would have had a subsection.

(The counters also exist for section, subsubsection etc)

B: Switching from 3 digits to 2 digits This is a bit unusual but can be achieved as follows:

\documentclass[english,11pt,a4paper]{article}

\usepackage{amsmath}
\newtheorem{theorem}{Theorem}
\numberwithin{theorem}{subsection}


\begin{document}
    \section{One}
    \subsection{Sub-One}
    \begin{theorem}
        content
    \end{theorem}
    
    \section{Two}
    %\addtocounter{subsection}{1}
    \numberwithin{theorem}{section}

    
    \begin{theorem}
        content
    \end{theorem}
    
\end{document}

This then gives the following document:

enter image description here

Note, that you might have to switch back to the "3 digit section numbering" by \numberwithin{theorem}{subsection} (adjust chapter/section/subsection to your case, of course).

You must log in to answer this question.

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