Set Theorem counter as subsection number + 0.1?

How to adjust counters for so that theorem is subsection+0.1 and the subsection number adjusts itself after the theorem. For example in the code below the output produces 1.1 subsection followed by the Theorem 1.1 (I want this to be Theorem 1.2) this is followed by 1.2 Another Subsection (I want this to 1.3).

I have tried using \addcounter and \setcounter but it does not produce the desired result.

\documentclass{article}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]

\begin{document}

\section{Test Section} some text
\subsection{subsection} blah
\begin{theorem}
How to set the theorem counter to 1.2 instead of 1.1 as in the output.
\end{theorem}
\subsection{Another subsection} How to set this counter to 1.3

\end{document}

• Welcome to tex.sx. If I understand your question correctly, you wish the theorem and subsection numbers to be in the same sequence. With amsthm, this can be done with \newtheorem{theorem}[subsection]{Theorem}. This is explained in answers to this question and the question it points to as a duplicate. Feb 25 at 18:36

You can set the theorem counter to be an alias (or duplicate) for the subsection counter using the methods described in Slave duplicate counter.

\documentclass{article}

\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]

\makeatletter
\newcommand*{\dupcntr}[2]{%
\expandafter\let\csname c@#1\expandafter\endcsname\csname c@#2\endcsname
}
\makeatother
\dupcntr{theorem}{subsection}

\begin{document}

\section{Test Section} some text

\subsection{subsection} blah
\begin{theorem}
How to set the theorem counter to 1.2 instead of 1.1.
\end{theorem}

\subsection{Another subsection} How to set this counter to 1.3

\end{document}

• Thank You so much. This helped a lot. Feb 25 at 18:47