`glossaries` 包不接受通过 `graphicx` 生成的某些符号

`glossaries` 包不接受通过 `graphicx` 生成的某些符号

我遇到了这个glossaries软件包的问题。出于某种原因,它甚至不接受通过某些命令构造的简单符号,例如来自graphicx。考虑以下 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}

如果取消注释词汇表条目的注释行,meinzeichen则会发生编译错误:

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

显然,我不会深入graphicx.sty研究文件并进行更改。为什么词汇表不接受由 生成的符号graphicx?更重要的是,我如何使用类似命令\rotatebox来处理词汇表条目中的符号?

提前致谢!

答案1

命令很脆弱,因此需要\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}

相关内容