我有一个词汇表,我喜欢用“参见第 x 页”结束每个条目。我之前添加了 \dotfill,以便我们可以看到“描述.......参见第 x 页”。不幸的是,换行符无法按预期工作。实际上,我希望 latex 预留足够的空间在一行上写“参见第 x 页”,否则它应该添加一个充满点的新行。
\documentclass{book}
\usepackage[showframe]{geometry}
\usepackage[xindy,toc,acronym,nopostdot]{glossaries}
\setglossarystyle{altlist}
\renewenvironment{theglossary}{%
\begin{description}[style=standard,labelindent=0pt,itemsep=5pt]%
}{\end{description}}
\renewcommand\glspostdescription{\def\hfill{\hskip 25pt plus 3fill}\dotfill \textit{see page}}
\renewcommand{\glsgroupskip}{}
\makeglossaries
\usepackage{enumitem}
\parindent 0in
\parskip 0.05in
\setlength{\textfloatsep}{0.8\baselineskip plus 0.2\baselineskip minus 0.2\baselineskip}
\newglossaryentry{Alpha}
{ name=Alpha,
description={Smoothing factor applied to the demand level in the various exponential smoothing models. In theory: \ensuremath{ 0 < \alpha \leq 1}, in practice: \ensuremath{0 < \alpha \leq 0.6}}}
\newglossaryentry{Gamma}
{ name=Gamma,
description={Smoothing factor applied to the seasonality (either additive or multiplicative) in the triple exponential smoothing models. In theory: \ensuremath{ 0 < \gamma \leq 1}, in practice: \ensuremath{0.05 < \gamma \leq 0.3}}}
\begin{document}
\glsaddall
\printglossary
\end{document}
答案1
我认为在这种情况下最好定义自定义样式。然后可以将“查看页面”和位置列表放在一个框内,这样可以防止其中出现任何换行:
\documentclass{book}
\usepackage[showframe]{geometry}
\usepackage{enumitem}
\usepackage[xindy,toc,acronym,nopostdot]{glossaries}
\makeatletter
\newglossarystyle{mystyle}{%
\setglossarystyle{altlist}%
\renewenvironment{theglossary}{%
\begin{description}[style=standard,labelindent=0pt,itemsep=5pt]%
}%
{\end{description}}
\renewcommand*{\glossentry}[2]{%
\item[\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}}]%
\mbox{}\par\nobreak\@afterheading
\glossentrydesc{##1}\glspostdescription
{\def\hfill{\hskip 25pt plus 3fill}\dotfill\mbox{\textit{see page} ##2}}%
}%
\renewcommand{\glsgroupskip}{}%
}
\makeatother
\setglossarystyle{mystyle}
\makeglossaries
\parindent 0in
\parskip 0.05in
\setlength{\textfloatsep}{0.8\baselineskip plus 0.2\baselineskip minus 0.2\baselineskip}
\newglossaryentry{Alpha}
{ name=Alpha,
description={Smoothing factor applied to the demand level in the various exponential smoothing models. In theory: \ensuremath{ 0 < \alpha \leq 1}, in practice: \ensuremath{0 < \alpha \leq 0.6}}}
\newglossaryentry{Gamma}
{ name=Gamma,
description={Smoothing factor applied to the seasonality (either additive or multiplicative) in the triple exponential smoothing models. In theory: \ensuremath{ 0 < \gamma \leq 1}, in practice: \ensuremath{0.05 < \gamma \leq 0.3}}}
\begin{document}
\glsaddall
\printglossary
\end{document}