词汇表页码问题

词汇表页码问题

我正在使用 lualatex,但遇到了一个问题,即词汇表中的页码有时会出现在单独的行上,如下图所示。我该如何避免这种情况?

页码单独一行

更新

我认为我已经将其归结为 scrbook 的这些设置组合,这些设置是在我们研究所提供的自定义文档类中设置的。所以剩下的问题是发生了什么,我该如何防止这种情况发生?

\documentclass[%
    fontsize=12pt,
    DIV=13,
    BCOR=8mm
]{scrbook}


% use glossaries and acronyms
\usepackage[indexonlyfirst]{glossaries}
% display glossary entries emphasized
\renewcommand*{\glsentryfmt}{\emph{\glsgenentryfmt}}
% dots between glossary description and page number
\renewcommand*\glspostdescription{\dotfill}

\newglossaryentry{pubmed}{
    name={Entrez PubMed},
    description={is a database of references and abstracts on life sciences
        and biomedical topics hosted by the NCBI affs fasjflkasjflajf fasfasf }
}


\makeglossaries
\begin{document}
\printglossaries

The \gls{pubmed} is awesome.

\end{document}

答案1

您的\dotfill命令是导致此现象的原因:它不能确保其后不出现换行符。

然而,除了避免断点之外,您还需要设置最少的点数。

\documentclass[%
    fontsize=12pt,
    DIV=13,
    BCOR=8mm
]{scrbook}


% use glossaries and acronyms
\usepackage[indexonlyfirst]{glossaries}
% display glossary entries emphasized
\renewcommand*{\glsentryfmt}{\emph{\glsgenentryfmt}}
% dots between glossary description and page number
\renewcommand*\glspostdescription{\mindotfill}
\makeatletter
\newcommand{\mindotfill}{%
  \leavevmode % switch to horizontal mode
  \penalty\z@ % possibly break here
  \mbox{}\nolinebreak % don't remove the leaders at the start of the line
  \cleaders\hb@[email protected]{\hss.\hss}\hskip 1.5em plus 1fill % fill with dots, at least 3
  \kern\z@ % don't remove the leaders at a break
  \nolinebreak % don't break here
}
\makeatother

\newglossaryentry{pubmed}{
    name={Entrez PubMed},
    description={is a database of references and abstracts on life sciences
        and biomedical topics hosted by the NCBI affs fasjflkasjflajf fasfasf}
}
\newglossaryentry{pubmed1}{
    name={Entrez PubMed1},
    description={is a database of references and abstracts on life sciences
        and biomedical topics hosted by the NCBI affs fasjflkasjflajf fasfasf 
        fasfasf fasfasf}
}
\newglossaryentry{pubmed2}{
    name={Entrez PubMed2},
    description={is a database of references and abstracts on life sciences
        and biomedical topics hosted by the NCBI affs fasjflkasjflajf fasfasf
        fasfasf fasfasf fasfsase}
}
\newglossaryentry{pubmed3}{
    name={Entrez PubMed3},
    description={is a database of references and abstracts on life sciences
        and biomedical topics hosted by the NCBI affs fasjflkasjflajf fasfasf
        fasfasf fasfasf fasfsasee}
}


\makeglossaries
\begin{document}
\printglossaries

The \gls{pubmed} is awesome. Also \gls{pubmed1}, \gls{pubmed2} and \gls{pubmed3}.

\end{document}

在此处输入图片描述

答案2

在找到正确答案之前,这里有一个窍门。

\renewcommand*\glspostdescription{\dotfill\kern1ex}

适当改变1ex

\documentclass[%
    fontsize=12pt,
    DIV=13,
    BCOR=8mm
]{scrbook}


% use glossaries and acronyms
\usepackage[indexonlyfirst]{glossaries}
% display glossary entries emphasized
\renewcommand*{\glsentryfmt}{\emph{\glsgenentryfmt}}
% dots between glossary description and page number
\renewcommand*\glspostdescription{\dotfill\kern1ex}

\newglossaryentry{pubmed}{
    name={Entrez PubMed},
    description={is a database of references and abstracts on life sciences
        and biomedical topics hosted by the NCBI affs fasjflkasjflajf fasfasf }
}


\makeglossaries
\begin{document}
\printglossaries

The \gls{pubmed} is awesome.

\end{document}

在此处输入图片描述

相关内容