Consider the following minimal example:
\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\newcommand{\NewS}[4]{
% Q1: How can I use argument #1 without the backslash in the following line?
\newglossaryentry{symb:#4}{
name=\ensuremath{#2},
description={\nopostdesc #3},
sort=sym#4,
}
% Q2: Why is the space between the '}' necessary?
\def#1{\ensuremath{#2} }
}
\NewS{\power}{P}{the power of something}{power}
\begin{document}
One can refer to the symbol via \power and \gls{symb:power} and.
\end{document}
The two questions I have are already inserted in the example. In particular I am searching for a way to remove the backlash of the string \power which I pass as a first argument to the newcommand so that I can write something like:
\newglossaryentry{symb:WITHOUT_BACKSLASH(#1)}{
And secondly I don't understand why I have to leave a space between the two braces in the \def in order to get "P and" in the output and not "Pand" - which is what I get when I remove the space. If I directly write \ensuremath{P} and I don't see any problems so I am just curious.
Thanks for your help!
Regards