我使用的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}