0

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}
\addtocontents{toc}{\cftpagenumbersoff{sec}} 
\addtocontents{toc}{\cftpagenumbersoff{subsec}} 
\addtocontents{toc}{\cftpagenumbersoff{subsubsec}} 
\section*{Section Name}
\addcontentsline{toc}{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

instead of the desired

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.

1 Answer 1

0

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]{%
\addtocounter{nc}{1}%
Theorem \thesection.\arabic{nc}. <<#1>> %
}{\vspace{1cm}}

and use it this way:

\begin{theorem}{Theoremname}
    Lorem Ipsum.
\end{theorem}
2
  • 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.
    – Jonne
    Nov 19, 2021 at 14:03
  • 1
    \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!
    – Jonne
    Nov 19, 2021 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.