I'm trying to make a command which will create a new theorem environment and link the counter for it to a specified other counter. For example, I'd like to be able to do something where my theorem, proposition, definition, etc. environments all have the same counters. I've tried the following:
\usepackage{etoolbox}
\usepackage{aliascnt}
\DeclareDocumentCommand{\DeclareTheorem}{ m m m !o }{%
\theoremstyle{#1}%
\IfNoValueTF{#4} {%
\newtheorem{#2}{#3}%
}{%
\newaliascnt{#2}{#4}%
\newtheorem{#2}[#2]{#3}%
}%
}
This doesn't seem to work. It doesn't throw an error, it just doesn't compile or something. If I require five arguments, as below, then it works.
\DeclareDocumentCommand{\DeclareTheorem}{ m m m m !o }{%
\theoremstyle{#1}%
\IfNoValueTF{#5} {%
\newtheorem{#2}{#3}%
}{%
\newaliascnt{#4}{#5}%
\newtheorem{#2}[#4]{#3}%
}%
}
However, I'd prefer to automatically have the alias counter to have the same name as the theorem environment, so that I don't have to put in five different options every time. Any help?