# Different counters for theorems, lemmas, definitions,

I don't know how I can create different counters for theorems, lemmas, definitions, observations, corollaries, examples and exercises. I'd like to have the numeration of these as chapter.section.subsection.number, where "number" stays for the number of theorem, lemma, ... . For example I'd like to have something like that:

Theorem (Pytagora) --- 1.1.1.1,

Lemma (Zorn) --- 1.1.1.1,

Theorem (Cayley--Hamilton) --- 1.1.1.2,

Corollary (of Theorem 1.1.1.2) --- 1.1.1.2.a,

Definition (Cauchy's succession) --- 1.1.1.1.

I hope in you help, Thank you so much Best Regards

• Then please show us how you define your theorems? A normal \newtheorem{theorem}[subsection] would be enough to make the first one. Commented Aug 5, 2021 at 10:36
• Thanks for answered me. I definine theorems like so: \newcommand{\namedtheoremname}{} \newtheorem{namedtheoreminner}[theorem]{\protect\namedtheoremname} \newenvironment{namedtheorem}[1] {% \renewcommand{\namedtheoremname}{#1}% \begin{namedtheoreminner}% } {\end{namedtheoreminner}}
– Puck
Commented Aug 5, 2021 at 10:56
• What is the reasoning for using inner here? Perhaps you should make a full minimal example such that others can get a better idea as to what you are doing. I also did a mistake in my first comment, it should have said \newtheorem{theorem}{Theorem}[subsection] Commented Aug 5, 2021 at 11:18
• I solved my problem. Thank you. Later, I'll answer my question
– Puck
Commented Aug 5, 2021 at 14:02

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amsthm}
\usepackage{stix}

%(Re)newcommands

\renewcommand\qedsymbol{$\blacksquare$}

%New 8 counters

\newtheorem{theorem}{Theorem}[subsection]

\newtheorem{definition}{Definition}[subsection]

\newtheorem{lemma}{Lemma}[subsection]

\newtheorem{corollary}{Corollary}[subsection]

\newtheorem{proposition}{Proposition}[subsection]

\newtheorem{example}{Example}[subsection]

\newtheorem{exercise}{Exercise}[subsection]

\newtheorem{observation}{Observation}[subsection]

%New Theorems

\newcommand{\namedtheoremname}{}
\newtheorem{namedtheoreminner}[theorem]{\protect\namedtheoremname}
\newenvironment{namedtheorem}[1]
{%
\renewcommand{\namedtheoremname}{#1}%
\begin{namedtheoreminner}%
}
{\end{namedtheoreminner}}

%New Definitions

\newcommand{\nameddefinitionname}{}
\newtheorem{nameddefinitioninner}[definition]{\protect\nameddefinitionname}
\newenvironment{nameddefinition}[1]
{%
\renewcommand{\nameddefinitionname}{#1}%
\begin{nameddefinitioninner}%
}
{\end{nameddefinitioninner}}

%New Lemmas

\newcommand{\namedlemmaname}{}
\newtheorem{namedlemmainner}[lemma]{\protect\namedlemmaname}
\newenvironment{namedlemma}[1]
{%
\renewcommand{\namedlemmaname}{#1}%
\begin{namedlemmainner}%
}
{\end{namedlemmainner}}

%New Corollaries

\newcommand{\namedcorollaryname}{}
\newtheorem{namedcorollaryinner}[corollary]{\protect\namedcorollaryname}
\newenvironment{namedcorollary}[1]
{%
\renewcommand{\namedcorollaryname}{#1}%
\begin{namedcorollaryinner}%
}
{\end{namedcorollaryinner}}

%New Propositions

\newcommand{\namedpropositionname}{}
\newtheorem{namedpropositioninner}[proposition]{\protect\namedpropositionname}
\newenvironment{namedproposition}[1]
{%
\renewcommand{\namedpropositionname}{#1}%
\begin{namedpropositioninner}%
}
{\end{namedpropositioninner}}

%New Examples

\newcommand{\namedexamplename}{}
\newtheorem{namedexampleinner}[example]{\protect\namedexamplename}
\newenvironment{namedexample}[1]
{%
\renewcommand{\namedexamplename}{#1}%
\begin{namedexampleinner}%
}
{\end{namedexampleinner}}

%New Exercises

\newcommand{\namedexercisename}{}
\newtheorem{namedexerciseinner}[exercise]{\protect\namedexercisename}
\newenvironment{namedexercise}[1]
{%
\renewcommand{\namedexercisename}{#1}%
\begin{namedexerciseinner}%
}
{\end{namedexerciseinner}}

%New Observations

\newcommand{\namedobservationname}{}
\newtheorem{namedobservationinner}[observation]{\protect\namedobservationname}
\newenvironment{namedobservation}[1]
{%
\renewcommand{\namedobservationname}{#1}%
\begin{namedobservationinner}%
}
{\end{namedobservationinner}}

\title{Theorem Proof, Stack}

\author{Name, Surname}
\begin{document}

\maketitle

\chapter{First Chapter}

\section{Theorems}
\subsection{Theorems}
\begin{namedtheorem}{First Theorem}
Statement.
\end{namedtheorem}
\begin{proof}
Its Proof.
\end{proof}

\begin{nameddefinition}{First Definition}

\end{nameddefinition}

\begin{nameddefinition}{Second Definition: Cauchy's Succession}
\end{nameddefinition}

\begin{namedlemma}{Zorn's Lemma}
Statement.
\begin{proof}
Its Proof.
\end{proof}
\end{namedlemma}

\end{document}


Observe this:

%New 8 counters

\newtheorem{theorem}{Theorem}[subsection]

\newtheorem{definition}{Definition}[subsection]

\newtheorem{lemma}{Lemma}[subsection]

\newtheorem{corollary}{Corollary}[subsection]

\newtheorem{proposition}{Proposition}[subsection]

\newtheorem{example}{Example}[subsection]

\newtheorem{exercise}{Exercise}[subsection]

\newtheorem{observation}{Observation}[subsection]


In this way it is possible create new counters and then use themselves like so:

% This is the main template for particular \LeTeX--Functions %

\newcommand{\namednewcountername}{}
\newtheorem{namednewcounterinner}[newcounter]{\protect\namednewcountername}
\newenvironment{namednewcounter}[1]
{%
\renewcommand{\namednewcountername}{#1}%
\begin{namednewcounterinner}%
}
{\end{namednewcounterinner}}


Here You can substutuite newcounter with theorem, lemma, proposition, ... .

THANK YOU