在阅读了词汇表包的手册后,我的印象是,当您使用排序键时,它将根据此排序键中给出的文本按字母顺序排序。然而,这个 MWE 并没有实现这一点(当然,实际上我有更多的符号,所以我真的需要自动排序,当我定义它们时,按正确的顺序定义它们会花很长时间)
\documentclass{report}
\usepackage{lipsum}
\usepackage[]{hyperref}
\usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
\makenoidxglossaries
\newglossaryentry{thetab}
{%
name={$\Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b ,
}
\newglossaryentry{thetaa}
{%
name={$\Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
\newglossaryentry{thetade}
{%
name={$\Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
\newglossaryentry{thetaOP}
{%
name={$\Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
\begin{document}
\printnoidxglossary[sort=standard,title={List of Symbols}]
\chapter{first chapter}
\lipsum
testing \gls{thetab} and \gls{thetaa}
some more references \gls{thetade} and \gls{thetaOP}
\end{document}
得出以下结果:
如果按字母顺序排列,我期望的顺序是这样的:
温度系数
温度系数
温度系数
OP 温度系数
我究竟做错了什么?
答案1
我不确定为什么standard
排序顺序不起作用,但如果你切换到它就可以正常工作letter
:
\documentclass{report}
\usepackage{lipsum}
\usepackage[]{hyperref}
\usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
\makenoidxglossaries
\newglossaryentry{thetab}
{%
name={$\Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b,
}
\newglossaryentry{thetaa}
{%
name={$\Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
\newglossaryentry{thetade}
{%
name={$\Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
\newglossaryentry{thetaOP}
{%
name={$\Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
\begin{document}
\printnoidxglossary[sort=letter,title={List of Symbols}]
\chapter{first chapter}
\lipsum
testing \gls{thetab} and \gls{thetaa}
some more references \gls{thetade} and \gls{thetaOP}
\end{document}
得出的结果为:
顺便说一句,如果您想按不同的字段(description
在本例中为)排序,您可以重新定义设置键值的钩子sort
。例如:
\documentclass{report}
\usepackage{lipsum}
\usepackage[]{hyperref}
\usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
\makenoidxglossaries
\makeatletter
\renewcommand{\glsprestandardsort}[3]{%
\protected@edef#1{\glsentrydesc{#3}}%
}
\makeatother
\newglossaryentry{thetab}
{%
name={$\Theta_{b}$},
description={temperature coefficient for b}
}
\newglossaryentry{thetaa}
{%
name={$\Theta_{a}$},
description={temperature coefficient for a}
}
\newglossaryentry{thetade}
{%
name={$\Theta_{de}$},
description={temperature coefficient for de}
}
\newglossaryentry{thetaOP}
{%
name={$\Theta_{OP}$},
description={temperature coefficient for OP}
}
\begin{document}
\printnoidxglossary[sort=letter,title={List of Symbols}]
\chapter{first chapter}
\lipsum
testing \gls{thetab} and \gls{thetaa}
some more references \gls{thetade} and \gls{thetaOP}
\end{document}
编辑:
更好的重新定义\glsprestandardsort
是:
\glssanitizesorttrue
\renewcommand{\glsprestandardsort}[3]{%
\glsfieldfetch{#3}{desc}{#1}%
\glsdosanitizesort
}
(这不再需要\makeatletter
...\makeatother
部分。)
该\glssanitizesorttrue
位将\glsdosanitizesort
应用于\@onelevel@sanitize
排序字段,这将允许像 这样的命令\si
出现在描述中(但它将应用与 相同的逻辑并将makeindex
视为\si
字符序列\
、s
和i
)。
的第二个参数\glsprestandardsort
是词汇表类型,因此您可以测试它以根据词汇表改变字段的设置方式sort
。例如:
\renewcommand{\glsprestandardsort}[3]{%
\ifthenelse{\equal{#2}{main}}%
{%
\glsfieldfetch{#3}{desc}{#1}%
}{}%
\glsdosanitizesort
}
答案2
删除排序键值中的空格:
\documentclass{report}
\usepackage{lipsum}
\usepackage[]{hyperref}
\usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
\makenoidxglossaries
\newglossaryentry{thetab}
{%
name={$\Theta_{b}$},
description={temperature coefficient for b},
sort=temperaturecoefficientforb,
}
\newglossaryentry{thetaa}
{%
name={$\Theta_{a}$},
description={temperature coefficient for a},
sort=temperaturecoefficientfora,
}
\newglossaryentry{thetade}
{%
name={$\Theta_{de}$},
description={temperature coefficient for de},
sort=temperaturecoefficientforde,
}
\newglossaryentry{thetaOP}
{%
name={$\Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperaturecoefficientforop,
}
\begin{document}
\printnoidxglossary[sort=standard,title={List of Symbols}]
\chapter{first chapter}
\lipsum
testing \gls{thetab} and \gls{thetaa}
some more references \gls{thetade} and \gls{thetaOP}
\end{document}