# Numbering inside restated theorem

I have a curious situation with equations inside a restatable theorem environment, when the theorem environment counter coincides with the equation counter:

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}

\usepackage{thmtools}
\usepackage{thm-restate}

\numberwithin{equation}{section}

\declaretheorem[
sibling=equation,%
name=Problem,%
prefoothook={\end{subequations}},%
]{problemstellung}

\begin{document}

\section{First}

$$T = A$$

\begin{problemstellung}
Das ist ein Problem
\end{problemstellung}

\begin{restatable}[Schwache Form der Elastizität]{problemstellung}{WeakFormMixedConfig}
\label{prop:WeakFormMixedConfig}
Finde ein $u: B \rightarrow R^3$, sodass \begin{align}
\int_{B} P : \eta d V &= \int_{B} \rho b_0 \cdot \eta d V \label{eqn:WeakFormMixedconfig} \\
P &= g(u)
\end{align}
\end{restatable}

Look a reference to the Problem: \ref{prop:WeakFormMixedConfig}

$$T = A$$
$$T = A$$

\WeakFormMixedConfig*

\end{document}


What happens is the following:

Which I did not intend. My Intention was to have a problem statement, which consists of 1 or more equations, which can then be restated in the following sections. It should follow the equation counter and it's equations for the problem description should be subequations. As in

Problem 1.4
equation 1.4a
equation 1.4b
equation 1.4c

equation 1.5


And in it's restated variant it should also have the same numbering

I am open for workarounds and solutions to this problem.

Since the problemstellung and equation counters are siblings, the value of the equation counter stored at the end of the restatable environment is one more than the problem counter. This is why the restated problem is 1.5 instead of 1.4. Also, every use of subequations steps the equation counter, which is why you go from Problem 1.2 to Problem 1.4 even though there are no visible equations between them. To fix this and make the equation number appear how you want, you can subtract 1 from equation at the beginning of each problem, except in the restated problem because it's already using the "frozen" counters from the original problem.

\documentclass{article}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}

\usepackage{thmtools}

\numberwithin{equation}{section}

\newif\ifrestateorig
\restateorigfalse
\newcommand{\fixeqncntr}{%
\ifrestateorig
\fi
}

\declaretheorem[
name=Problem,%
sibling=equation,
prefoothook={\end{subequations}},%
]{problemstellung}

\begin{document}

\section{First}

$$T = A$$

\begin{problemstellung}
Das ist ein Problem
\end{problemstellung}

\begin{restatable}[Schwache Form der Elastizität]{problemstellung}{WeakFormMixedConfig}
\label{prop:WeakFormMixedConfig}
Finde ein $u: B \rightarrow R^3$, sodass \begin{align}
\int_{B} P : \eta d V &= \int_{B} \rho b_0 \cdot \eta d V \label{eqn:WeakFormMixedconfig} \\
P &= g(u)
\end{align}
\end{restatable}

Look a reference to the Problem: \ref{prop:WeakFormMixedConfig}

$$T = A$$
$$T = A$$

\WeakFormMixedConfig*

\end{document}