![如何为多个词汇表条目设置相同的类型?](https://linux22.com/image/448500/%E5%A6%82%E4%BD%95%E4%B8%BA%E5%A4%9A%E4%B8%AA%E8%AF%8D%E6%B1%87%E8%A1%A8%E6%9D%A1%E7%9B%AE%E8%AE%BE%E7%BD%AE%E7%9B%B8%E5%90%8C%E7%9A%84%E7%B1%BB%E5%9E%8B%EF%BC%9F.png)
我使用的glossaries
软件包有两个词汇表,一个用于一般定义,一个用于数学符号。似乎对于符号词汇表的每个条目,我都必须单独输入type=notation
选项。而不是
\newglossaryentry{letter:A}{
type=notation,
name={\ensuremath{\mathcal{A}}},
description={This is the letter A.},
}
\newglossaryentry{letter:B}{
type=notation,
name={\ensuremath{\mathcal{B}}},
description={This is the letter A.},
}
\newglossaryentry{letter:C}{
type=notation,
name={\ensuremath{\mathcal{C}}},
description={This is the letter C.},
}
...
我更希望有一个更紧凑的解决方案,例如\setglossarytype{notation}
这样我就可以写
\setglossarytype{notation}
\newglossaryentry{letter:A}{
name={\ensuremath{\mathcal{A}}},
description={This is the letter A.},
}
\newglossaryentry{letter:B}{
name={\ensuremath{\mathcal{B}}},
description={This is the letter A.},
}
\newglossaryentry{letter:C}{
name={\ensuremath{\mathcal{C}}},
description={This is the letter C.},
}
...
相反。这能做到吗?
如果需要,请提供完整的 MWE:
\documentclass{article}
\usepackage{glossaries}
\newglossary[nlg]{notation}{not}{ntn}{Notation}
\makeglossaries
\newglossaryentry{letter:A}{
type=notation,
name={\ensuremath{\mathcal{A}}},
description={This is the letter A.},
}
\newglossaryentry{letter:B}{
type=notation,
name={\ensuremath{\mathcal{B}}},
description={This is the letter A.},
}
\newglossaryentry{letter:C}{
type=notation,
name={\ensuremath{\mathcal{C}}},
description={This is the letter C.},
}
\begin{document}
\gls{letter:A} comes before \gls{letter:B}, and then \gls{letter:C} at the end.
\printglossary[type=notation]
\end{document}
答案1
您可以按照自己喜欢的方式引入 \newcommand,例如:
\documentclass{article}
\usepackage{glossaries}
\newglossary[nlg]{notation}{not}{ntn}{Notation}
\newcommand\nge[1]{ % <<< -----------------
\newglossaryentry{letter:#1}{
type=notation,
name={\ensuremath{\mathcal{#1}}},
description={This is the letter #1.},
}
}
\makeglossaries
\newglossaryentry{letter:A}{
type=notation,
name={\ensuremath{\mathcal{A}}},
description={This is the letter A.},
}
\newglossaryentry{letter:B}{
type=notation,
name={\ensuremath{\mathcal{B}}},
description={This is the letter A.},
}
\newglossaryentry{letter:C}{
type=notation,
name={\ensuremath{\mathcal{C}}},
description={This is the letter C.},
}
\nge{D} % <<< -----------------
\nge{E} % <<< -----------------
\begin{document}
\gls{letter:A} comes before \gls{letter:B}, and then \gls{letter:C} at the end.
What's about \gls{letter:E} and \gls{letter:D}?
\printglossary[type=notation]
\end{document}