0

Is there a way to force hyphenation even when it would generate overfull hboxes? I read here (texfaq.org) that when tex can't find a resolution that doesn't overfill the line, it just gives up with a warning. I have many situations in my document where a word hangs over the line, but it could be hyphenated to hang less far over (oftentimes much less far). Explicitly adding hyphenation marks doesn't help, I guess because the line would still be overfull.

Update with example

Ok, I guess this is an ill-formed question because my understanding of the texfaq article must have been incorrect. I'll explain what I think is happening in case either

  • someone else makes the same mistake I did, or
  • someone can correct my further misunderstanding(s).

Here's an example showing that tex does indeed hyphenate even when hboxes would be overfull. (I don't know if it matters that I'm using the cleveref package, but I am so I included it.)

Note: The explicit settings of textwidth and hyphenation are just for the purposes of this example.

\documentclass[draft]{amsbook}
\textwidth=49mm

\usepackage[english]{babel}
\usepackage[capitalise]{cleveref}

\newtheorem{corollary}{Corollary}

\hyphenation{corol-lary}
\begin{document}

\noindent
aaaaaaaaaaaaaaaaaaaaaaaaaa \cref{testcor}.

\begin{corollary}\label{testcor}
  a a a a a a a a a a a a a a 
\end{corollary}

\setcounter{corollary}{999}

\noindent
aaaaaaaaaaaaaaaaaaaaa \cref{testcor-b}.

\begin{corollary}\label{testcor-b}
  a a a a a a a a a a a a a a 
\end{corollary}

\end{document}

The output looks like this:

enter image description here

In the line referring to Corollary 1, there is hyphenation even though the hbox is overfull. In the line referring to Corollary 1000, no hyphenation occurs because it's too close to the end of the word. Furthermore, tex doesn't separate the number 1000 from the word, and that is the desired behavior.

I don't actually have 1000 corollaries in my document, but I do have numbers like 3.4.21 to refer to corollary 21 of section 4 of chapter 3. Looking again, most of my long overfull hboxes are because the numbers are so long. I suppose there's nothing to be done about that other than \sloppy (or changing \tolerance some other way) or rewording.

4
  • 3
    why are you getting so many overfull boxes? do you have the correct language set? as you have posted no code hard to guess, try adding \sloppy Jul 17, 2021 at 13:21
  • Ok, thanks @DavidCarlisle for the nudge to do more testing/examples. I've included one now, and doing so made me realize that I must have misunderstood that texfaq post. I edited my question with some further explanation. To answer your question about why so many, it's just a really long document (for a book). I believe I have set the language correctly. I just didn't want to go so far as \sloppy since (I think) that's even more distracting.
    – Niles
    Jul 17, 2021 at 14:34
  • 1
    The added examples are a bit suspect because the first "word" will never be hyphenated without explicit action (a TeX "given") and the fact that there are only two spaces in the line provides minimal options for breaking. Using the sloppypar environment limits the scope of the sloppiness, and is actually almost unnoticeable when applied sparingly. Jul 17, 2021 at 17:58
  • thanks @barbarabeeton; I didn't want to manually put in sloppypar, because the choice of which paragraphs need it will probably change with the publisher's margins. (And also there are a lot of paragraphs.) But I did add some emergencystretch, which sounds like it's kind of the same thing. (maybe?) An emergencystretch of 10pt reduced the number of overfull hboxes in one chapter from 16 (with three of them overfull by more than 20pt) to 4 (with 13pt the largest), so that seems quite a bit better.
    – Niles
    Jul 18, 2021 at 11:38

1 Answer 1

1
\hyphenation{corol-lary}

doesn't actually do anything as that is the default. If you allow a few more hyphenation points

\hyphenation{cor-ol-l-ary}

You get a better lienbreak:

enter image description here

Well I say it's better there is no right and wrong here, but breaking after the double l doesn't seem too bad to me.

Or you can keep the default hyphenation, but allow a bit of space around the cref-inserted word. I don't know the package that well so I added the space as part of the word (there may be a better interface). If you add

 \Crefname{corollary}{\hspace{0pt plus 1pt}Corollary\hspace{0pt plus 1pt}}{Corollaries}%

Then you get

enter image description here

6
  • Thanks! I was a little worried about adding more hyphenation points, because I don't understand the rules (of grammar) very well. But maybe you're telling me there are no rules!! I agree that the hyphenation cor-o-l-l-ary seems pretty reasonable (to me). Allowing the break between the word and the number is little less pleasant to me. But I guess your point might be that I should decide whether it's more or less pleasant than running the text into the margin so far. Thanks a lot for the suggestions.
    – Niles
    Jul 18, 2021 at 11:50
  • 1
    @Niles In English there are no rules (about anything much:-) but especially about hyphenation, the default US ones (you are using) are loosely based on a Merriam-webster dictionary data as I recall and the British English ones you can select with babel were based on some data provided (but not public) by Oxford University press Jul 18, 2021 at 12:06
  • 1
    @Niles -- It's not that there are no rules (although there's some disagreement between the U.S. and the UK about exactly what they are), but there are some things that I think we'll agree on. One such is that "ll" is not a unit, so the hyphen you propose between "l" won't fly. \emergencydtretch is a good approach; see tex.stackexchange.com/a/241355 for a discussion. Jul 18, 2021 at 15:00
  • @barbarabeeton try tex '\showhyphens{corollary}' Jul 18, 2021 at 16:54
  • 1
    @DavidCarlisle -- Yes, I did that before, and got \tenrm corol-lary. I was objecting to the possibility of coro-llary, I hope the UK patterns don't allow that ... Jul 18, 2021 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .