3

The numbering scheme I'm looking for causes every environment to share one common numbering counter, according to subsection. For example, in my notes the numbering would look something like this:

1 Section #1

2 Section #2

2.1 Subsection #2.1
2.1.1 Definition
2.1.2 Lemma
2.1.3 Theorem
      Proof
2.1.4 Corollary
2.1.5 Example
      Solution

2.2 Subsection #2.2
2.2.1 Definition
2.2.2 Lemma
2.2.3 Theorem
      Proof
2.2.4 Corollary
2.2.5 Example
      Solution

Below is a MWE:

\documentclass{article}
\usepackage{amsmath,amsfonts,amssymb,amsthm,thmtools}

\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

% THEOREM Environments
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{result}[theorem]{Result}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
numberwithin=section
]{exstyle}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
headpunct={},
qed=$\blacksquare$,
numbered=no
]{solstyle}
\declaretheorem[style=exstyle]{example}
\declaretheorem[style=solstyle]{solution}

\begin{document}
\section{Section 1}
\section{Section 2}
\subsection{Subsection 2.1}
\begin{definition}
test
\end{definition}
\begin{lemma}
content...
\end{lemma}
\begin{theorem}
content...
\end{theorem}
\begin{proof}
content...
\end{proof}
\begin{example}
content...
\end{example}
\begin{solution}
content...
\end{solution}

\subsection{Subsection 2.2}
\begin{definition}
test
\end{definition}
\begin{lemma}
content...
\end{lemma}
\begin{theorem}
content...
\end{theorem}
\begin{proof}
content...
\end{proof}
\begin{example}
content...
\end{example}
\begin{solution}
content...
\end{solution}

\end{document}

Except all the numbering is off.

I'm not sure if what I want is unconventional (and please let me know if there are any downsides to what I'm asking for).

By the way, most of this code was borrowed from different sources, e.g. the example environment was borrowed from this question, because I wanted an environment (without numbering) similar to the proof environment except with a filled-in square instead of a hollow square.

I must admit that the more code I copy from others, the less I understand the resulting code I end up with. As an unfortunate consequence, I have no idea what the different parts of the command \newtheorem{theorem}{Theorem}[section] mean, nor what the parts of \newtheorem{corollary}[theorem]{Corollary} mean. Please feel free to share any advice you have with me. You can safely assume my LaTeX understanding is novice. Thank you for your help!

  • \newtheorem{theorem}{Theorem}[subsection] – egreg Apr 12 '15 at 22:37
  • Ah okay... that fixes part of it! But Example is still on a different numbering system though... How can I make the Example environment fit in with the others? – Mathemanic Apr 12 '15 at 23:03
5

When you say,

\newtheorem{theorem}{Theorem}[section]

the theorem is numbered within section. Since you want it to be numbered within subsection make it

\newtheorem{theorem}{Theorem}[subsection]

as already commented by egreg.

Further, when you write

 \newtheorem{corollary}[theorem]{Corollary}

The corollary and theorem share the same counter i.e., they are numbered consecutively.

Now that you are also using thmtools for styling (styling can be done with amsthm too but thmtools is bit more equipped), things will change to like

numberwithin=section

Here again, you have to change it to

numberwithin=subsection

So that the follow the same. For details, it is always good to refer to the documentation, which, can be obtained by visiting the site texdoc.net and typing the name of the package (for example, thmtools) in the search window there and hitting enter. Alternatively, you may open a command line/prompt in your computer and type texdoc thmtools there to get a local copy (which is already ther in your computer). Please remember that your tex editor also supports the texdoc, look in its help menu.

Here is your modified code.

\documentclass{article}
\usepackage{amsmath,amsfonts,amssymb,amsthm,thmtools}

\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}

% THEOREM Environments
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[subsection]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{result}[theorem]{Result}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
numberwithin=subsection
]{exstyle}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
postheadspace=1em,
headpunct={},
qed=$\blacksquare$,
numbered=no
]{solstyle}
\declaretheorem[style=exstyle]{example}
\declaretheorem[style=solstyle]{solution}

\begin{document}
\section{Section 1}
\section{Section 2}
\subsection{Subsection 2.1}
\begin{definition}
test
\end{definition}
\begin{lemma}
content...
\end{lemma}
\begin{theorem}
content...
\end{theorem}
\begin{proof}
content...
\end{proof}
\begin{example}
content...
\end{example}
\begin{solution}
content...
\end{solution}

\subsection{Subsection 2.2}
\begin{definition}
test
\end{definition}
\begin{lemma}
content...
\end{lemma}
\begin{theorem}
content...
\end{theorem}
\begin{proof}
content...
\end{proof}
\begin{example}
content...
\end{example}
\begin{solution}
content...
\end{solution}

\end{document}

enter image description here

  • Very well explained, Harish... Thank you very much! – Mathemanic Apr 12 '15 at 23:28

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.