For math symbols or operators I open create a custom command such as
\newcommand{\prob}[2]{%
\ifthenelse{\isempty{#2}}%
{%
p( #1 )
}{%
p( #1 \mid #2 )%
}%
}%
to capture the cases where I want to type a conditional or a un-conditional probability with one command, and to be able to change the notation easily if I find out that it is suboptimal.
Now, I also want to create a list of symbols and index using glossaries where I would use e.g.
\glsxtrnewsymbol[description={Probability density functon}]{prob}{\ensuremath{\prob{\cdot}}}
To get the glossary and index right, I would be obliged to use e.g. \gls{prob} (instead of \prob) also e.g. in an align environment and $$ math, correct?
But in this case, I cannot make use of the function \prob that I defined beforehand.
Now the question: Is there an efficient way to deal with this? I.e. to define (complex) functions that capture multiple possible use cases and make use of the glossary?
Naively speaking, it would be perfect to 'overload' the \gls with the options declared for \prob, is that possible?