# How to number a lemma in reference to the next theorem?

In a document I'd like to be able to write lemmas and theorems such that I always write lemmas before the theorem they support and those lemmas are numbered in reference to the theorem they support. I current have this setup:

\theoremstyle{plain}
\newtheorem{thrm}{Theorem}[section]
\newtheorem{lemm}{Lemma}[thrm]


For example, it produces a numbering scheme like this:

Theorem 1.1. text text text.

Lemma 1.1.1. text text text.

Lemma 1.1.2. text text text.

Theorem 1.2. text text text.

Lemmas 1.1.1 and 1.1.2 would support the following theorem 1.2 however they are numbered in a way that makes them look like lemmas of theorem 1.1. Instead I would want those lemmas to be numbered 1.2.1 and 1.2.2.

What can I do to resolve this?

If Lemmas always precede the Theorem they reference, you can just add one to the theorem counter's representation:

\documentclass{article}

\usepackage{amsthm,xfp}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[theorem]

\renewcommand{\thelemma}{\thesection.\inteval{\value{theorem}+1}.\arabic{lemma}}

\begin{document}

\section{A section}

\begin{theorem}
This is the first theorem.
\end{theorem}

\begin{lemma}
This is the first lemma.
\end{lemma}

\begin{lemma}
This is the second lemma.
\end{lemma}

\begin{theorem}
This is the second theorem.
\end{theorem}

\end{document}