Open muzimuzhi opened 3 years ago
Suppose
\declaretheorem{theorem, definition}[<key>=theorem]
does the work, then the logic is "use key value (theorem) as sibling value, or ignore it if it is the same as the env name to be defined". It seems this logic can be directly added to the existing keysibling
, because normally it's non-sense to use\declaretheorem{env}[sibling=env]
.
This solely could be implemented as simple as
diff --git a/source/thm-kv.dtx b/source/thm-kv.dtx
index 7859126..dd34ecd 100644
--- a/source/thm-kv.dtx
+++ b/source/thm-kv.dtx
@@ -409,7 +409,9 @@
\@nx\thmt@newtheorem
\ifthmt@isnumbered
{#1}%
- \ifx\thmt@sibling\@empty\else [\thmt@sibling]\fi
+ \ifx\thmt@sibling\@empty
+ \else\ifx\thmt@sibling\thmt@envname
+ \else [\thmt@sibling]\fi\fi
{\thmt@thmname}%
\ifx\thmt@parent\@empty\else [\thmt@parent]\fi
\else
A continued example:
\documentclass{article}
\usepackage{thmtools}
\usepackage{xpatch}
\makeatletter
\xpatchcmd\declaretheorem@iii
{\ifx\thmt@sibling\@empty\else [\thmt@sibling]\fi}
{\ifx\thmt@sibling\@empty
\else\ifx\thmt@sibling\thmt@envname
\else [\thmt@sibling]\fi\fi}
{}{\fail}
\makeatother
\declaretheorem{theorem, definition}[sibling=theorem]
\begin{document}
\begin{theorem} content \end{theorem}
\begin{definition} content \end{definition}
\begin{theorem} content \end{theorem}
\end{document}
This will give the desired output.
But since sibling/numberlike
and parent/numberwithin
are mutually exclusive, the above patch will NOT resolve José's request: use
\declaretheorem[style=theorem, numberwithin=chapter]
{theorem, lemma, proposition, corollary}
to define env theorem
numbered within chapter
, and all the following envs numbered like theorem
.
José's proposal, a new boolean option siblings
, is closer (to the final decision).
Use case:
Define multiple theorem environments simultaneously and make them share the same counter. So with
one will get
(from user José Gil Férez by email)
Discussions:
Suppose
\declaretheorem{theorem, definition}[<key>=theorem]
does the work, then the logic is "use key value (theorem) as sibling value, or ignore it if it is the same as the env name to be defined". It seems this logic can be directly added to the existing keysibling
, because normally it's non-sense to use\declaretheorem{env}[sibling=env]
.Cons: This requires that the
sibling
value to be the first one in the env list. As a counterexample,\declaretheorem{theorem, definition}[sibling=definition]
won't work.