[Tex/LaTex] Hyphenation with Acronyms

acronymsglossarieshyphenationtilde

I have difficulties getting hyphenation right in long acronyms with user-defined hyphenation rules when trying to prevent line breaks between the long and the short form.

\documentclass{article}

\usepackage{showframe}

\hyphenation{mi-cros-co-py}

\begin{document}
\paragraph{Long Text} This is some text abcdefgh Acronym Containing Microscopy~(ACM).
\paragraph{Longer Text} This is some text abcdefgh Acronym Containing Microscopy~(ACM).
\paragraph{Even Longer Text} This is some text abcdefgh Acronym Containing Microscopy~(ACM).

\paragraph{Another try} Let's try manual hyphenation.

\paragraph{Long Text} This is some text abcdefgh Acronym Containing Mi\-cros\-co\-py~(ACM).
\paragraph{Longer Text} This is some text abcdefgh Acronym Containing Mi\-cros\-co\-py~(ACM).
\paragraph{Even Longer Text} This is some text abcdefgh Acronym Containing Mi\-cros\-co\-py~(ACM).

\paragraph{Another try} Let's also skip the non-breaking space.

\paragraph{Long Text} This is some text abcdefgh Acronym Containing Mi\-cros\-co\-py (ACM).
\paragraph{Longer Text} This is some text abcdefgh Acronym Containing Mi\-cros\-co\-py (ACM).
\paragraph{Even Longer Text} This is some text abcdefgh Acronym Containing Mi\-cros\-co\-py (ACM).

\end{document}

MWP

As can be seen from the MWP, in certain cases the typesetting ends up in overfull hboxes even without the non-breaking space and manual hyphenation.
Setting \hyphenpenalty=0 in the preamble doesn't help either, same result.

What am I missing here?

Strictly speaking, I am using the glossaries package in my actual document with adjusted acronym formatting including the non-breaking space before the short form: \renewcommand{\acrfullformat}[2]{#1~(#2)} I replaced these parts with plain text for the MWP as the result is the same. Just in case anybody knows about a solution based on glossaries to solve this issue.

Best Answer

Assuming you don't want a break within (ACM) then adding more hyphenation points (or reducing the penalty for hyphenation) won't help. You need to allow white space to stretch to allow the line to fill up after you have broken.

\begin{document}\setlength\emergencystretch{1.5em}

produces no overfull lines (although the lines produced are a bit spacy)

enter image description here