如何在词汇表中使用 amsmath 环境 \Bmatrix?

如何在词汇表中使用 amsmath 环境 \Bmatrix?

我想使用 amsmath-package 中的以下环境来获取词汇表条目,但是 latex 失败了(带有 pdflatex 的 TexStudio):

\开始{B矩阵}...\结束{B矩阵}

这是我的 MWE:

\documentclass{scrbook}
\usepackage{amsmath}
\usepackage{glossaries}
%
\begin{document}
\section{in Textmode everything is fine}
$\begin{Bmatrix}W_{ij}\end{Bmatrix}$, brackets with the required height
%
\section{trying the same using glossaries}
%
the working one:\par
%
\newglossaryentry{mat:Wij}{%
name=\ensuremath{\left\{W_{ij}\right\}},
description={working entry, tensor brackets manually}
}%
%
\gls{mat:Wij}, Problem: brackets don´t have the required height\\
\\ 
%%
the one with the following mistake:\par
line 30: Undefined control sequence. \} \\  
%
%\newglossaryentry{mat:Mij}{%
%name=\ensuremath{
%\begin{Bmatrix}
%M_{ij}
%\end{Bmatrix}},
%description={entry with mistake, tensor brackets by Bmatrix-command}
%}%
%%
%\gls{mat:Mij}, brackets with the required height
\end{document}

答案1

问题是由于扩张

工作版本:

\documentclass{scrbook}
\usepackage{amsmath}
\usepackage{glossaries}

\glsnoexpandfields

\newglossaryentry{mat:Mij}{%
name=\ensuremath{
\begin{Bmatrix}
M_{ij}
\end{Bmatrix}},
description={entry with mistake, tensor brackets by Bmatrix-command}
}

\newglossaryentry{mat:Wij}{%
name=\ensuremath{\left\{W_{ij}\right\}},
description={working entry, tensor brackets manually}
}%

\begin{document}
\section{in Textmode everything is fine}
$\begin{Bmatrix}W_{ij}\end{Bmatrix}$, brackets with the required height

\section{trying the same using glossaries}

the working one:


\gls{mat:Wij}, Problem: brackets don´t have the required height

the one with the following mistake:\par
line 30: Undefined control sequence. \}  

\gls{mat:Mij}, brackets with the required height
\end{document}

我推荐你将你的定义移至序言(正如我上面所做的那样)。如果你真的想在文档中使用它们,请使用

\usepackage[docdefs=restricted]{glossaries-extra}

代替

\usepackage{glossaries}

如果您打算添加\printglossaries,请记住添加sort这些条目的密钥:

\newglossaryentry{mat:Mij}{%
sort={Mij},
name=\ensuremath{
\begin{Bmatrix}
M_{ij}
\end{Bmatrix}},
description={entry with mistake, tensor brackets by Bmatrix-command}
}

\newglossaryentry{mat:Wij}{%
sort={Wij},
name=\ensuremath{\left\{W_{ij}\right\}},
description={working entry, tensor brackets manually}
}

相关内容