Change subsection numbering style from ‘A.1’ to ‘A’ for only one section in article document

numberingsubsection

I have not found a way to remove everything after the initial number (in my case a letter) from subsection numbering of a particular section in an article document. I have

Section
A.1 subsection
B.2 subsection
C.3 subsection

and I want

Section
A subsection
B subsection
C subsection

I thought that I could dig the answer out of this question but I couldn't. I didn't find any related questions, only questions that change subsections of the whole document. I managed to put the letters in instead of numbers with this code:

\newcounter{alphasect}
\def\alphainsection{0}

\let\oldsection=\subsection
\def\subsection{%
    \ifnum\alphainsection=1%
    \addtocounter{alphasect}{1}
    \fi%
    \oldsection}%

\renewcommand\thesection{%
    \ifnum\alphainsection=1% 
    \Alph{alphasect}
    \else%
    \arabic{section}
    \fi%
}%

\newenvironment{alphasection}{%
    \ifnum\alphainsection=1%
    \errhelp={Let other blocks end at the beginning of the next block.}
    \errmessage{Nested Alpha section not allowed}
    \fi%
    \setcounter{alphasect}{0}
    \def\alphainsection{1}
}{%
    \setcounter{alphasect}{0}
    \def\alphainsection{0}
}%

I use it as follows

\begin{alphasection}
%all the subsections
\end{alphasection}

I barely understand LaTeX, this is my second document. I got the code above from this site and intuitively I would say, that the desired result is obtainable by modifying the same script. I would appreciate a solution very much so I could go on with writing my thesis instead of wondering LaTeX-programming.

EDIT: the question is about changing one section, not all the sections of the document. So \renewcommand\thesubsection{\Alph{subsection}} does not help. Zarko's other suggestion is a good hack, but unfortunately leaves the subsections out from the table of contents. They should be there.

Best Answer

Well two things. First, the problem is here:

\renewcommand\thesection{%
    \ifnum\alphainsection=1% 
    \Alph{alphasect}
    \else%
    \arabic{section}
    \fi%
}%

You're changing the numbering of sections, not subsections. Changing it to:

\renewcommand\thesubsection{%
    \ifnum\alphainsection=1% 
    \Alph{alphasect}
    \else%
    \arabic{subsection}
    \fi%
}%

should give the desired results. But, I would be more inclined to scrap all of this in favor of:

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

Note that in general, \NewDocumentEnvironment ❶ (along with \NewDocumentCommand and their relatives) is preferable to \newcommand for defining new commands.

Environments execute within a group, meaning that any redefinitions ❷ will revert at the end of the environment. Also, here we define the subsection number using \RenewExandableDocumentCommand so that we'll get the correct value if there is a reference to the number or if it's printed in the table of contents.