\documentclass{article} \usepackage{amsmath} \usepackage{mdframed} \usepackage{amsthm} \usepackage{thmtools} \usepackage{mkessler-hypersetup} \usepackage{verbatim} \usepackage{mkessler-refproof} \def\cname#1{\texttt{$\backslash$#1}} \NewDocumentEnvironment{remark}{!s o} \newcounter{all} \declaretheorem[sibling = all]{definition} \declaretheorem[sibling = all, name = Theorem ]{intntheorem} \declaretheorem[sibling = all, name = Theorem*]{intstheorem} \declaretheorem[sibling = all, name = Theorem$^{\dagger}$]{intdtheorem} \declaretheorem[sibling = all, parent = section ]{testthm} \declaretheorem[sibling = all, parent = section ]{lemma} \NewDocumentEnvironment{theorem}{ !s !t+ } { \IfBooleanTF{#1} { \begin{intstheorem} } { \IfBooleanTF{#2} { \begin{intdtheorem} } { \begin{intntheorem} } } } { \IfBooleanTF{#1} { \end{intstheorem} } { \IfBooleanTF{#2} { \end{intdtheorem} } { \end{intntheorem} } } } \addtotheorempreheadhook{test} \addtotheorempostheadhook{test} \begin{document} \section{What we need} \subsection{Groups / classes of theorems} These share some properties and are controlled via options. Things an environment should change dynamically: \begin{itemize} \item parent, sibling \item title: variants with * or $^{\dagger}$ \end{itemize} \subsection{Greater Syntax for theorems} Expand the \cname{NewDocumentEnvironment}-like syntax to theorems as well. \subsection{Example Code} \begin{verbatim} \NewTheoremGroup { all } [ ] \NewTheoremGroup { big } [ thmtools = { sibling = insection } ] \NewTheoremGroup { dagger } [ postname = { $\dagger$ }, thmtools = { sibling = insubsection } ] \NewTheoremGroup { small } [ thmtools = { sibling = insubsection } ] \NewTheoremGroup { star } [ thmtools = { sibling = insubsection }, postname = { * } ] \NewTheoremGroup { starred } [ thmtools = { numbered = no } ] \DeclareTheoremVariants { theorem } { !s !t+ o} { \AddTheoremToGroup { big } \IfBooleanT {#1} { \AddTheoremToGroup{star} } \IfBooleanT {#2} { \AddTheoremToGroup{daggered} } } \end{verbatim} \subsection{Syntax} \begin{verbatim} \NewTheoremGroup {} [ thmtools = {}, prename = , postname = , mapname = , ] \NewGroupedTheorem [ thmtools = {}, group = {} \NewDocumentTheorem{}{} { any legal xparse code that issues the commands \AddTheoremToGroup{} and \PassToThmtools{} \PassAsOptionalArgument{} } \end{verbatim} Last case: For the powerset of the mentioned theorems, generate internal theorem variants, that are part of the corresponding groups, where in the document, the signature will be calling the corresponding theorem variant automatically. A typical declaration would thus be: \begin{verbatim} \NewDocumentTheorem{theorem}{ !s !t+ o} { \IfBooleanT{#1}{ \AddTheoremToGroup{star} } \IfBooleanT{#2}{ \AddTheoremToGroup{dagger} } \PassAsOptionalArgument{#3} } \end{verbatim} \section{Testing} \begin{theorem}\label{normal} test \end{theorem} \begin{theorem}*\label{star} \end{theorem} \begin{theorem}+[comment]\label{dagger} test \end{theorem} \def\foo#1.#2ab#3.\end{foo: #1 #2 #3} \foo 1.2ab3.\end \section{test}\label{sec} \section*{test} \phantomsection\label{sec2} \autoref{sec} \autoref{sec2} \begin{theorem} \end{theorem} \autoref{test} \begin{theorem}[test] bla \end{theorem} \begin{definition} \end{definition} normal:~\autoref{normal}, star:~\autoref{star}, dagger:~\autoref{dagger} \begin{testthm} \end{testthm} \begin{lemma} bla \end{lemma} \end{document}