Is it possible to use \gls
(from the glossaries
package) inside a caption without \protect
ing it every single time? The glossaries
package says the \gls
command is not fragile… but I get errors unless I protect it.
Kind of annoying since half the advantage of a glossary
/acronym
package is reducing the amount of typing you have to repeat.
\documentclass{article}
\usepackage{caption}
\usepackage{glossaries}
\newglossaryentry{Name}{name={Name},description={Description}}
\makeglossaries
\begin{document}
\begin{figure}[h]
\caption{Blah blah \protect\gls{name}}
\end{figure}
\end{document}
If you remove the protect it will complain about an extra }.
Best Answer
The
glossaries
package loads theetoolbox
package by default. And,etoolbox
provides\robustify{<command>}
that redeclares<command>
as a robust (non-fragile) command. Therefore, addafter loading
glossaries
.