I am defining symbols in my document with glossaries-extra package such as:
\glsxtrnewsymbol[description={Lagrangian}]{lag}{\ensuremath{\mathit{L}}}
However I will be referring to this in my document very often -mostly inside equations-. Normally if I wouldnt have to have a list of symbols I would define
\newcommand{\lag}{\mathit{L}}
and simply write \lag everywhere inside the equation. Now I either need to use \gls{lag} everytime, or for each glossary-symbol entry I should use the \newcommand as above. My question is isnt there a way to tell latex to print \gls{label} whenever I type \label ?
....editing after @schtandard's comments.....
So a MWE is this
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[symbols,nonumberlist]{glossaries-extra}
\makeglossaries
\glsxtrnewsymbol[description={Field on Minima spce}]{minfield}{\ensuremath{\varphi}}
\glsxtrnewsymbol[description={General Field}]{field}{\ensuremath{\phi}}
\newcommand{\field}{\gls{field}}
\newcommand{\minfield}{\gls{minfield}}
\begin{document}
I have a configuration space with fields $\field$ that has a minima. Fields on the minima space are called $\minfield$.
\begin{equation}
\delta V (\field=\minfield)=0
\end{equation}
\clearpage
\printglossaries
\end{document}
What I want is not to have to define \newcommand
s at all, but still be able get the result I get with the exact same code in between \begin{document}
and end{document}
. Probably what I want is something like,
\newsymbol{#1,#2,#3}
{
\glsxtrnewsymbol[description={#1}]{#2}{#3},
\newcommand{\#2}{#3}
}
I dont know if something like that already exists or possible, I am new to this level of latex.
...edit 2... I have been using the solution suggested by @egreg happily and i think it helped me quite a lot. I have tried to use the same thing for acronyms, however I come across a small problem. Let me explain. Consider the following code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[acronyms,nomain,shortcuts]{glossaries-extra}
\newcommand{\acryn}[3]{%
\newacronym{#1}{#2}{#3}%
\expandafter\newcommand\csname #1\endcsname{\acs{#1}}}%
\newcommand{\acryntwo}[3]{%
\newacronym{#1}{#2}{#3}%
\expandafter\newcommand\csname #1\endcsname{\acs{#1}~}}%
\makeglossaries
\acryn{gr}{GR}{General Relativity}
\acryntwo{grtwo}{GR}{General Relativity}
\begin{document}
If I use the glossary package command I can say \acs{gr} and it prints nicely. But if I use the command I define when I say \gr unfortunately no gap appears.\\
I could add tilde to the command and this problem would be solved \grtwo as one can see, but now the gap appears where I do not want it to appear: (\grtwo). Note that this does not happen with the built-in command: (\acs{gr}).
\printglossary[type=\acronymtype]
\end{document}
which produces this:
\newcommand\lag{\gls{lag}}
? Please add an MWE that shows the current behavior and that we can use to provide a solution for you.