[Tex/LaTex] Referencing Definition by Name and Optional Argument

cross-referencingtheorems

I have the following MWE:

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}

\newtheorem*{definition}{Definition}

\begin{document}

\section{Section Definitions}

\begin{definition}[symmetric matrix]
    \label{def:sym.mat}
    A quadratic matrix $X$ is called \emph{symmetric}, if $X^{\dagger} = X$. 
\end{definition}

This is a reference to \autoref{def:sym.mat}. 
\end{document}

The Output of the reference sentence is:

This is a reference to section 1.

I want to get:

This is a reference to Definition (symmetric matrix).

I know how to cross-reference different theorem-like environments like lemma, theorem with the aliascnt package. But my definitions, unlike theorems, are not numbered but instead contain an unique phrase in rectangular brackets on what they define.

Is there a way to overload \label and \ref or \autoref so that the displayed text for the reference is the composite of the environment name (here 'Definition') and the optional argument (here 'symmetrix matrix')? Maybe analog to this answer in Reference name of description list item in LaTeX.

I want to avoid defining a manual reference display text for each definition environment. I guess I somehow have to update \@currentlabel with \thmnote?
If this questions was already asked & answered, I am happy if somebody points me to it.

Best Answer

Help \autoref by telling it what kind of reference it's defined.

A new counter is needed so that \autoref will use it for its purpose; next a name for it is needed; then the counter is refstepped when the optional argument is found and the label is set to the name in parentheses.

\documentclass{article}
\usepackage{amsthm}
\usepackage{xparse}
\usepackage{hyperref}

\newtheorem*{innerdefinition}{Definition}
\newcounter{definition}
\providecommand{\definitionname}{Definition}

\makeatletter
\NewDocumentEnvironment{definition}{o}
 {%
  \IfValueTF{#1}
    {\innerdefinition[#1]\refstepcounter{definition}\def\@currentlabel{(#1)}}%
    {\innerdefinition}%
 }
 {%
  \endinnerdefinition
 }
\makeatother

\begin{document}

\section{Section Definitions}

\begin{definition}[symmetric matrix]
    \label{def:sym.mat}
    A quadratic matrix $X$ is called \emph{symmetric}, if $X^{\dagger} = X$. 
\end{definition}

This is a reference to \autoref{def:sym.mat}. 
\end{document}

enter image description here

Related Question