To number the subsection, I use
\renewcommand*\thesubsection{\thesection.\arabic{subsection}}
It works well for the normal numbered sections. For example, if we use
\section{A}
\subsection{try}
\subsection{try2}
it shows
1. A
1.1. try
1.2. try2
However, if one section is not numbered, the subsections within it looks weird. For example, if we write
\section*{A}
\subsection{try}
\subsection{try2}
we get
A
.1. try
.2. try
How can I write a macros to make an automatic judgement: if the section is numbered, this number is added to subsection numbering; if the section is not numbered, we directly number subsection by itself? As an example, I want to get
1. A
1.1. A1
1.2. A2
B
1. B1
2. B2
\subsection
. Then use:\renewcommand*\thesubsection{\arabic{subsection}}
at the point where you want the redefinition to take place. You will probably also have to reset the subsection counter:\setcounter{subsection}{0}
. (But, really, don't do this.).