How can I customise numbering of theorems, definitions etc. inside one customised section of an article document?

I have a section with suppressed numbering (\section*{Section Name}) in which I use the following code for switching the numbers of subsections to letters.

\NewDocumentEnvironment{alphasection}{}
{%
\RenewExpandableDocumentCommand{\thesubsection}{} %
{\Alph{subsection}}%
}
{}


So the document looks like

\newpage
\setcounter{page}{1}
\section*{Section Name}
Some text with citations.
\begin{alphasection}
\subsection{Subsection Name}\label{Label}
Some text.
.
.
.
\subsection{Last Subsection Name}\label{Label}
Some text.
\end{alphasection}


Everything is ok, except that the numbering of theorems and definitions does not match the letters of the subsections. The numbering is as if the theorems and definitions were in the previous section, which happens to be number 6. So I have

A Subsection Name
Definition 6.9
Theorem 6.10
B Subsection Name
Theorem 6.11


A Subsection Name
Definition A.1
Theorem A.2
B Subsection Name
Theorem B.1


Is it possible to somehow modify the alphasection code so that it would take care of numbering, too? Elsewhere numbering theorems etc. follows section numbers so other sections have numbering like below.

3 Section Name
Definition 3.1
Theorem 3.2
Lemma 3.3
3.1 Subsection Name
Definition 3.4
Lemma 3.5
Theorem 3.6

etc. ​


For this one section I want numbering (lettering?) based on subsection letters. I have read several questions and as far as I understand LaTeX (that's not much), none of the questions were about this problem. Every bit of advice is appreciated.

You can use this syntax:

\newtheorem{mytheorem}{Theorem}[subsection]


or use numberwithin command as it is said here

Also you can define environment this way:

\newcounter{nc}

\newenvironment{theorem}[1]{%

\begin{theorem}{Theoremname}

• The alternative you describe in your answer does not work. It produces odd formatting, but doesn't change anything else. I didn't understand the \newtheorem{mytheorem}{Theorem}[subsection] yet and it seems to me that it cannot be used because I have the document full of theorems and definitions named "theorem x.y" and "definition j.k". My intuition is, that using \newtheorem{mytheorem}{Theorem}[subsection] will change all of those, too. Nov 19, 2021 at 14:03
• \newtheorem{mytheorem}{Theorem}[subsection] works. I can't edit the first comment anymore so I posted this new one. Thank you for helping me out! Nov 19, 2021 at 14:11