我有一个文档,我想在其中添加带有简短描述的变量列表。因此我想使用该glossaries
包。如果词汇表仅包含普通文本,它会起作用,但由于我需要下标和上标,所以我总是会收到错误
未定义控制序列。}
我只想要一个包含数学变量的词汇表以及旁边以某种对齐(类似表格)形式出现的简短描述。
任何帮助都值得赞赏,谢谢!这是一个简单的例子:
\documentclass{report}
\usepackage{amsmath,amssymb,amsthm,makeidx,amsxtra,amscd}
\usepackage[toc,nonumberlist,nopostdot]{glossaries}
\usepackage{glossary-mcols}
\setglossarystyle{long}
\makeglossaries
\newglossaryentry{firstvar}
{
name={$\iRab$},
description={Description 1}
}
\newglossaryentry{secondvar}
{
name=bw,
description={Description 2}
}
\newcommand{\iRab}{{}^{}_{I}R^{}_{ab}}
\begin{document}
\glsaddall
\printglossary[title=Symbols and Notation]
\iRab
\end{document}
相关.log
部分:
(./document.gls [1
\openout3 = `document.ist'.
{/usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
LaTeX Font Info: Try loading font information for U+msa on input line 5.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsa.fd
File: umsa.fd 2013/01/14 v3.01 AMS symbols A
)
LaTeX Font Info: Try loading font information for U+msb on input line 5.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsb.fd
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
))
! Missing $ inserted.
<inserted text>
$
l.26 \iRab
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
! Missing $ inserted.
<inserted text>
$
l.27 \end{document}
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.
[2
] (./document.aux) )
答案1
问题不在于词汇表,而在于新命令。您需要修复两个问题:
- 你需要确保它处于数学模式
\ensuremath
- 您需要在第一次使用新命令之前让它出现。
平均能量损失
\documentclass{report}
\usepackage{amsmath,amssymb,amsthm,makeidx,amsxtra,amscd}
\usepackage[toc,nonumberlist,nopostdot]{glossaries}
\usepackage{glossary-mcols}
\setglossarystyle{long}
\makeglossaries
\newcommand{\iRab}{\ensuremath{{}^{}_{I}R^{}_{ab}}}
\newglossaryentry{firstvar}
{
name={$\iRab$},
description={Description 1}
}
\newglossaryentry{secondvar}
{
name=bw,
description={Description 2}
}
\begin{document}
\glsaddall
\printglossary[title=Symbols and Notation]
\iRab
\end{document}
答案2
使用此代码,编译时不会出现任何错误。
\documentclass{report}
\usepackage{amsmath,amssymb,amsthm,makeidx,amsxtra,amscd}
\usepackage[toc,nonumberlist,nopostdot]{glossaries}
\usepackage{glossary-mcols}
\setglossarystyle{long}
\newcommand{\iRab}{${}^{}_{I}R^{}_{ab}$}
\makeglossaries
\newglossaryentry{firstvar}
{
name={\ensuremath{\iRab}},
description={Description 1}
}
\newglossaryentry{secondvar}
{
name=bw,
description={Description 2}
}
\begin{document}
\glsaddall
\printglossary[title=Symbols and Notation]
\iRab
\end{document}