Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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

share|improve this answer
    
it would really be better to restrict this change to the relevant portions of the text. and if it's just particular paragraphs that are affected, wrapping just those paragraphs in \begin{sloppypar} ... \end{sloppypar} restricts the damage to only the places where it's absolutely needed. –  barbara beeton Mar 13 at 13:31
    
@barbarabeeton yes although sloppy(par) is more sloppy than just adding emergencystretch –  David Carlisle Mar 13 at 13:45
    
one can (and sometimes does) redefine \sloppypar to fine-tune the degree of sloppiness. –  barbara beeton Mar 13 at 13:47
    
@barbarabeeton Redefine standard latex commands? Shocking. Who'd do a thing like that..... –  David Carlisle Mar 13 at 13:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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