Imagine I have an acronym entry \newacronym{rmse}{RMSE}{root-mean-square error}
and I specifically want to refer to the test set RMSE, explaining eg. the concept of cross-validation. Imagine furthermore that I cannot (or do not want to) assert the status of the first use flag of that entry at some particular point in the document.
Things like test set \gls{rmse}
will not work properly on first use, because it will produce something like “test set root-mean-square error (RMSE)”, but I would rather have it display “test set root-mean-square error (test set RMSE)”, to avoid confusion about what exactly “RMSE” stands for.
I could use a construction like \gls{rmse} on the test set
, but find it very inelegant, especially in the non-first-use case.
Below is a MWE showing my current workaround using a combination of ifglsused
and some other glossaries
commands:
\documentclass{article}
\usepackage{glossaries}
\newacronym{rmse}{RMSE}{root-mean-square error}
\newcommand*{\mygls}[2]{%
\ifglsused{#2}{%
% short
#1 \gls{#2}%
}{%
% long
#1 \glsentrylong{#2} (#1 \glsentryshort{#2})\glsunset{#2}%
}%
}
\begin{document}
Step 4: Compute the \mygls{test set}{rmse}.
Step 4: Compute the \mygls{test set}{rmse}.
\end{document}
As can be seen, this works quite well, but is very inflexible (I might want to \myGls
or \myglspl
, for example).
Is there a better way to do this? Preferably, a glossaries
or glossaries-extra
command that I somehow happened to oversee?
Thanks!