3

Consider following MWE

\documentclass{scrartcl}
\usepackage{xspace}
\makeatletter
\newcommand\BC{\,v.\,Chr\@ifnextchar.{}{.\relax\@\xspace}}
\newcommand\AD{\,n.\,Chr\@ifnextchar.{}{.\relax\@\xspace}}
\makeatother

\usepackage{glossaries}
\makeglossaries

\newglossaryentry{Augustus}{%
  name={\textbf{Augustus}},% 
  description={Imperator 
    Caesar Divi Filius Augustus, geboren 63\BC, gestorben 14\AD, regierte von 27\BC bis 14\AD.},
  first={Augustus (27\protect\BC--14\protect\AD)}
}

\begin{document}
  \gls{Augustus}

  \printglossaries
\end{document}

All is fine and works as expected:

enter image description here

But I dont understand why the protect-commands in first={Augustus (27\protect\BC--14\protect\AD)} are necessary since I do not need them in description?

1

Some fields are expanded by default and some aren't. These are described in more detail in section 4.4 Expansion in the glossaries manual, but essentially the name, description and symbol fields aren't expanded by default and all others are. The sort key is an exception which is covered by the sanitizesort package option. Those fields that are expanded must have fragile commands protected.

To switch off all expansion use \glsnoexpandfields. Specific fields can have the expansion switched off with \glssetnoexpandfield{field}. This individual setting overrides the \glsexpandfields setting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.