3

I want the numbering of claims, subclaims, subsubclaims, etc to be hierarchically numbered. Is there a way to do this without having to make those extra "subclaim" environments? For example:

\documentclass{article}
\usepackage{amsmath,amsthm,amssymb}
\newtheorem{thm}{Theorem}
\newtheorem{claim}{Claim}[thm]

\begin{document}
\begin{thm}
this has a long proof. i break it up into smaller claims.
\end{thm}

\begin{claim}
i prove a smaller piece of the theorem. 
this proof makes its own even smaller claims.
\end{claim}

\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}
\end{document}

This example produces the following numbering:

Theorem 1

Claim 1.1

Claim 1.2

Ideally, I would want the numbering to go like:

Theorem 1

Claim 1.1

Claim 1.1.1

since the last claim "belongs" to the claim before it.

Some of the solutions I've seen accomplish this by making an extra "subtheorems" wrapper environment. Is there a simpler way?

2
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Commented Apr 24, 2016 at 2:11
  • I think that using sub theorems is much easier. In addition, I don't think claim hierarchy is really useful
    – user31729
    Commented Apr 24, 2016 at 6:46

2 Answers 2

1

Maintaining a stack of such levels is not really easy. I tried to provide this down to six levels, which automatic backup etc. and up/down levelling if needed.

There's an issue with a reusage of the claim environment when \holdlevelfalse is used. I'll try to figure out this.

Use the command \claimhierarchies{claim}{6}{thm}, meaning six levels, the 'parent' level is thm. then.

\documentclass{article}
\usepackage{amsmath,amsthm,amssymb}


\usepackage{xparse}
\usepackage{xpatch}
\usepackage{chngcntr}%

\newtheorem{thm}{Theorem}

\newcounter{claimlevel}[thm]

\newtheorem{claim}{Claim}[thm]


\ExplSyntaxOn


\newcommand{\claimhierarchies}[3]{%
  \newcounter{#1i}
  \expandafter\renewcommand\csname the#1i\endcsname{\bfseries \csname the#3\endcsname.\arabic{#1i}}%
  \int_step_inline:nnnn {2}{1}{#2}{%
    \newcounter{#1\romannumeral##1}[#1\romannumeral\numexpr##1-1]
    \expandafter\renewcommand\csname the#1\romannumeral##1\endcsname{\csname the#1\romannumeral\numexpr ##1-1\endcsname.\arabic{#1\romannumeral\numexpr##1}}
  }
}

\seq_new:N \g_claimcounter_stack_seq


\newcommand{\pushcounter}[1]{%
  \seq_gpush:Nn \g_claimcounter_stack_seq {#1}
}  

\newcommand{\popcounter}[1]{%
  \seq_pop:NN \g_claimcounter_stack_seq \l_tmpa_tl
  \setcounter{#1}{\l_tmpa_tl}%
} 


\newcommand{\getcounter}[1]{%
  \seq_get:NN \g_claimcounter_stack_seq \l_tmpa_tl
  \setcounter{#1}{\l_tmpa_tl}%
} 

\ExplSyntaxOff




\makeatletter

\newif\ifholdlevel
\newif\iflevelup
\newif\ifverbose
\verbosetrue


\newcommand{\levelup}{%
  \ifnum\c@claimlevel > 1
  \addtocounter{claimlevel}{\m@ne}
  \ifverbose
  Level up to Level \Roman{claimlevel}
  \fi
  \leveluptrue
  \fi
}




\AtBeginEnvironment{claim}{%
  \iflevelup
  \csletcs{theclaim}{theclaim\romannumeral\numexpr\c@claimlevel}
  \csletcs{c@claim}{c@claim\romannumeral\c@claimlevel}
  \else
  \ifholdlevel
  \ifverbose
  Hold Level on Level \Roman{claimlevel}
  \fi
  \csletcs{theclaim}{theclaim\romannumeral\numexpr\c@claimlevel}
  \csletcs{c@claim}{c@claim\romannumeral\c@claimlevel}
  \else
  \addtocounter{claimlevel}{1}%
  \ifverbose
  Level down to Level \Roman{claimlevel}
  \fi
  \pushcounter{\number\value{claim}}%
  \csletcs{theclaim}{theclaim\romannumeral\numexpr\c@claimlevel} % 
  \csletcs{c@claim}{c@claim\romannumeral\c@claimlevel}
  \fi
  \fi
}

\makeatother


\claimhierarchies{claim}{6}{thm}


\begin{document}
\begin{thm}
this has a long proof. i break it up into smaller claims.
\end{thm}

\begin{claim}
i prove a smaller piece of the theorem. 
this proof makes its own even smaller claims.
\end{claim}

\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}


\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}


\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}


\holdleveltrue


\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}


\levelup

\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}



\levelup

\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}

\holdleveltrue

\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}

\holdlevelfalse
\levelupfalse


\begin{claim}
i prove a claim made in the previous claim environment.
\end{claim}


\end{document}

enter image description here

2
  • \expandafter used inside \ExplSyntaxOn? Oh, my! ;-)
    – egreg
    Commented Apr 24, 2016 at 21:36
  • @egreg: Yes, I have to change that. It's a quick fix
    – user31729
    Commented Apr 25, 2016 at 3:20
1

The claim environment accepts an optional argument, default =, that's used to climb up or down a level. With + you go one level up, with - one level down; it's also possible to jump down two or three levels with -- and ---.

\documentclass{article}
\usepackage{amsthm,xparse,etoolbox}

\newtheorem{theorem}{Theorem}
\newtheorem{Claim}{Claim}[theorem]
\newtheorem{ClaimI}{Claim}[Claim]
\newtheorem{ClaimII}{Claim}[ClaimI]
\newtheorem{ClaimIII}{Claim}[ClaimII]
\newcounter{claimlevel}[theorem]

\ExplSyntaxOn
\NewDocumentEnvironment{claim}{O{=}}
 {
  \str_case:nn { #1 }
   {
    {=}  { }
    {+}  { \stepcounter{claimlevel} }
    {-}  { \addtocounter{claimlevel}{-1} }
    {--} { \addtocounter{claimlevel}{-2} }
    {---}{ \addtocounter{claimlevel}{-3} }
   }
  \begin{ Claim \int_to_Roman:n { \value{claimlevel} } }
 }
 {
  \end{ Claim \int_to_Roman:n { \value{claimlevel} } }
 }
\ExplSyntaxOff

\begin{document}

\begin{theorem}
This has a long proof. I break it up into smaller claims.
\end{theorem}

\begin{claim}
I prove a smaller piece of the theorem. 
This proof makes its own even smaller claims.
\end{claim}

\begin{claim}[+]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[+]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[-]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[-]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[+]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[-]
I prove a claim made in the previous claim environment.
\end{claim}


\begin{theorem}
This has a long proof. I break it up into smaller claims.
\end{theorem}

\begin{claim}
I prove a smaller piece of the theorem. 
This proof makes its own even smaller claims.
\end{claim}

\begin{claim}[+]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[+]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[--]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[+]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[+]
I prove a claim made in the previous claim environment.
\end{claim}

\begin{claim}[--]
I prove a claim made in the previous claim environment.
\end{claim}

\end{document}

enter image description here

1
  • 1
    Providing more than four levels is possible, but, I hope, not needed.
    – egreg
    Commented Apr 24, 2016 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .