[Tex/LaTex] Theorem numbering without the section and subsection numbers

numberingtheorems

I wish to number my theorems within subsections as

Theorem 1
Theorem 2
Theorem 3

And only reset it back to 1 when I have a new subsection.

So I have a subsection within a section, and within the subsection I have several theorems, which are normally numbered section.subsection.theoremnumber.
But I want it just to be Theorem 1, Theorem 2, Theorem 3, etc until the end of the subsection, and in the next subsection, reset it back to Theorem 1, Theorem 2, etc.

How can I do this?

Best Answer

Specify the theorem to renew with every \subsection, and then remove the subsection counter from the theorem counter representation:

enter image description here

\documentclass{article}

\newtheorem{thm}{Theorem}[subsection]% theorem counter resets every \subsection
\renewcommand{\thethm}{\arabic{thm}}% Remove subsection from theorem counter representation

\begin{document}

\section{A section}
\subsection{A subsection}
\begin{thm}\end{thm}
\begin{thm}\end{thm}
\begin{thm}\end{thm}
\subsection{A subsection}
\begin{thm}\end{thm}
\begin{thm}\end{thm}
\begin{thm}\end{thm}

\section{A section}
\subsection{A subsection}
\begin{thm}\end{thm}
\begin{thm}\end{thm}
\begin{thm}\end{thm}
\subsection{A subsection}
\begin{thm}\end{thm}
\begin{thm}\end{thm}
\begin{thm}\end{thm}

\end{document}