5

I am using lualatex and I have an issue where the page numbers in my glossary would sometimes appear on a seperate line, like in the picture below. How can I prevent this?

page number on seperate line

UPDATE

I think I have it boiled down to this combination of settings for scrbook, which are set in a custom documentclass provided by our institute. So the question that remains is what is happening and how can I prevent this?

\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
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Paul Gaborit Dec 1 '14 at 11:00
5

Your \dotfill command is the cause for the phenomenon: it doesn't ensure a line break is not taken after it.

However, you want to set a minimum number of dots, besides avoiding the break.

\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@xt@.44em{\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}

enter image description here

2

Until a proper answer comes, here is a hack. Put

\renewcommand*\glspostdescription{\dotfill\kern1ex}

Change 1ex suitably.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.