In another question (Remove math from command parameter to get only the letters) this command was elaborated to have an optional argument for sorting purposes within the index
\documentclass{article}
\usepackage{makeidx}
\usepackage{xparse}
\NewDocumentCommand{\defined}{om}{%
{\bfseries #2}%
\IfNoValueTF{#1}
{\index{#2}\label{#2}}
{\index{#1@#2}\label{#1}}
}
\makeindex
\begin{document}
\defined{$G$-invariant}
\defined[G-invariant]{$G$-invariant}
\printindex
\end{document}
I now wonder if theres a way to have the same optional argument for an own theorem style, so something along that line.
\newtheoremstyle{blanksample} % name of the style to be used
{} % measure of space to leave above the theorem
{} % measure of space to leave below the theorem
{} % name of font to use in the body of the theorem
{} % measure of space to indent
{\bfseries} % name of head font
{} % punctuation between head and body
{\newline} % space after theorem head
{\thmname{#1} \thmnumber{#2.} \thmnote{\normalfont(#3)} \defined{#1!#3}} % head
But like this I again have the problem with dollar signs or other stuff within #3 and therefore again would like to use an optional parameter and could hand this over to \defined.
Furthermore I actually would like to have the index link to the theorem number and not the page number.
Any ideas?
So I would like to use it somehow like this
Using \theoremstyle{blanksample} anf for \newtheorem{definition}{Definition} I would like to use it somehow like this
\begin{definition}[G-invariant][$G$-invariant]
some definition
\end{definition}