我目前正在为我的硕士论文编写词汇表,我想将 3 条开普勒定律嵌套在通用的“开普勒定律”条目下,但能够独立调用其中任何一个。
我想要的一个例子:
entry 1
blah, blah, blah
...
Kepler's Laws
Kepler 1st law
blah, blah, blah
Kepler 2nd law
blah, blah, blah
Kepler 2nd law
blah, blah, blah
...
entry last
blah, blah, blah
你知道怎样做吗?
我当时正在思考类似的事情:
\documentclass{ThesisClass}
\usepackage{glossaries}
\begin{document}
\newglossaryentry{Kepler1st}{name = Kepler\'{}s 1\textsuperscript{st} Law , description = First law,}
\newglossaryentry{Kepler2nd}{name = Kepler\'{}s 2\textsuperscript{nd} Law , description = second law,}
\newglossaryentry{Kepler3rd}{name = Kepler\'{}s 3\textsuperscript{rd} Law , description = third law,}
\newglossaryentry{KeplerLaws}{name = Kepler Laws of orbital movement , description = \glsentryfull{Kepler1st}\\\\glsentryfull{Kepler2nd}\\\\glsentryfull{Kepler3rd}\\ ,}
\printglossary[style=altlist,title=Nomenclature]
\makeglossaries
\end{document}
但这样做不起作用,我只会在 KeplerLaws 下得到空括号。最糟糕的情况是,我只会创建 3 个条目,仅此而已,但更愿意将它们嵌套在一起。
答案1
您应该定义一种自定义样式来实现您想要的效果。
这是基于默认样式的示例index
。请注意,只有当您有一个级别的子级时才可以使用它。
\documentclass{article}
\usepackage{glossaries}
\newglossaryentry{KeplerLaws}{name = {Kepler Laws of orbital movement}, description = {Kepler laws}}
\newglossaryentry{Kepler1st}{name = {Kepler\'{}s 1\textsuperscript{st} Law}, description = {First law}, parent = {KeplerLaws}}
\newglossaryentry{Kepler2nd}{name = {Kepler\'{}s 2\textsuperscript{nd} Law}, description = {Second law}, parent = {KeplerLaws}}
\newglossaryentry{Kepler3rd}{name = {Kepler\'{}s 3\textsuperscript{rd} Law}, description = {Third law}, parent = {KeplerLaws}}
\newglossarystyle{mystyle}{%
\glossarystyle{index}%
\renewcommand*{\glossaryentryfield}[5]{%
\item\glsentryitem{##1}\textbf{\glstarget{##1}{##2}}%
\ifx\relax##4\relax
\else
\space(##4)%
\fi
\subitem##3\glspostdescription \space ##5}%
\renewcommand*{\glossarysubentryfield}[6]{%
\ifcase##1\relax
% level 0
\item
\or
% level 1
\subitem
\glssubentryitem{##2}%
\else
% all other levels
\subsubitem
\fi
\textbf{\glstarget{##2}{##3}}%
\ifx\relax##5\relax
\else
\space(##5)%
\fi
\subsubitem##4\glspostdescription\space ##6}%
}
\makeglossaries
\begin{document}
\glsaddall
\printglossary[style=mystyle,title=Nomenclature]
\end{document}
输出