1

I'm having issues with the glossaries package. For some reason, it just will not accept even simple symbols constructed via certain commands, e.g. from graphicx. Consider the following MWE:

\documentclass[a4paper, 10pt]{scrbook}

\usepackage{
    amsmath,
    graphicx,
    glossaries, % <— changing the order does not help
}

\newglossaryentry{naturals}{
    sort={N},
    name={\ensuremath{N}},
    description={The set of naturals, $\{0,1,2,\ldots\}$.}
}
\newglossaryentry{meinzeichen}{
    sort={Symb},
    % name={a\rotatebox[origin=c]{90}{I}b}, % <— from graphicx package. Glossaries won't accept it.
    name={test}, % <— obvs works.
    description={A special operation.}
}
\makeglossaries

\begin{document}
    \printglossaries

    \section*{Main test}
    Consider the set $N=\{0,1,2,\ldots\}$.\glsadd{naturals}
    Now consider the relation \glsadd{meinzeichen}
\end{document}

If one uncomments the commented line for the glossary entry, meinzeichen, a compile-error occurs:

! Incomplete \iffalse; all text was ignored after line 19.
<inserted text> 
                \fi 

Obviously, I'm not going to dig into the graphicx.sty file and change things. Why won't glossaries accept symbols generated by graphicx? More importantly, how can I used commands like \rotatebox for symbols in glossary entries?

Thanks in advance!

1

The commands are fragile so need \protect

\documentclass[a4paper, 10pt]{scrbook}

\usepackage{
    amsmath,
    graphicx,
    glossaries, % <— changing the order does not help
}

\newglossaryentry{naturals}{
    sort={N},
    name={\ensuremath{N}},
    description={The set of naturals, $\{0,1,2,\ldots\}$.}
}
\newglossaryentry{meinzeichen}{
    sort={Symb},
     name={a\protect\rotatebox[origin=c]{90}{I}b}, % <— from graphicx package. Glossaries won't accept it.
    %name={test}, % <— obvs works.
    description={A special operation.}
}
\makeglossaries

\begin{document}
    \printglossaries

    \section*{Main test}
    Consider the set $N=\{0,1,2,\ldots\}$.\glsadd{naturals}
    Now consider the relation \glsadd{meinzeichen}
\end{document}
  • Thank you! Your solution worked. If I have defined my own macros, and these in turn are built from other macros, do I have to write \protect everywhere? If so, is there a way to „recursively“ protect a macro? – Thomas Jul 17 at 8:18

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.