I want to have a theorem environment with an additional required argument:
\begin{mylemma}{text1, text2}
It holds that True.
\end{mylemma}
\begin{mylemma}{text1, text2}[Name]
It holds that True.
\end{mylemma}
The output should look like this:
Lemma 1.1 [text1, text2]. It holds that True.
Lemma 1.2 (Name) [text1, text2]. It holds that True.
I tried using the answers provided here, here, here and here, but got none to work. The closest I got was the following:
\documentclass{book}
\usepackage{amsmath, amsthm}
\usepackage{thmtools}
\declaretheoremstyle[%
within=chapter,%
notefont=\normalfont\itshape,%
notebraces={}{},%
]{mystyle}
\declaretheorem[style=mystyle,name=Lemma]{mydef}
\newenvironment{mylemma}[2]
{\begin{mydef}[{(}#2{)\ [}#1{]}]}
{\end{mydef}}
\begin{document}
\begin{mylemma}{text1, text2}{Name}
It holds that True.
\end{mylemma}
\end{document}
This allows me to use \begin{mylemma}{text1, text2}{Name}\end{mylemma}
, but the argument I want to be optional is now required. Also, it would be nice to be able to write the following instead of defining new environments so verbosely:
\newtheoremstyle{mystyle}{}...{}
\theoremstyle{mystyle}
\newtheorem{mylemma}[theorem]{Lemma}
\newtheorem{mytheorem}[theorem]{Theorem}
\newtheorem{mycorollary}[theorem]{Corollary}
\newtheorem{myproposition}[theorem]{Proposition}
and then being able to use each environment like specified above. I tried to adapt the answer provided here for that, but apart from then having two optional arguments, I got an error possibly related to other packages I use (Package ntheorem Error: Theorem style plain already defined. ...rfont ##1\ ##2\ (##3)\theorem@separator}}
). Edit: a MWE for that modification:
\documentclass{book}
\usepackage{amsmath, amsthm}
\usepackage{mathtools, xparse}
\usepackage{ntheorem}
\makeatletter
\newtheoremstyle{mystyle}
{\isastyleaux{##1}{##2}}
{\isastyleaux{##1}{##2}[##3]}
\NewDocumentCommand\isastyleaux{mmou\ignorespaces o}
{\item[\theorem@headerfont\hskip\labelsep
#1\ #2%
\IfValueT{#3}{\normalfont\itshape (#3)}%
\IfValueT{#5}{\normalfont\itshape [#5]}%
.\theorem@separator]#4\ignorespaces}
\makeatother
\theoremstyle{mystyle}
\newtheorem{mylemma}{Lemma}
\begin{document}
\begin{mylemma}[text1, text2][Name]
It holds that True.
\end{mylemma}
\end{document}
Best Answer
Define an inner theorem and a new environment.
Here's how to move the period after the part in square brackets, with
amsthm
(but notntheorem
and you shouldn't load both).