[Tex/LaTex] Repetition of a word on two lines

line-breakingluatextypography

This question led to a new feature in a package:
impnattypo

There have been questions about rivers asked in the past. I'm wondering about words that are repeated in the same place on two consecutive lines, like "le monde" in the following example:

example of a word repetition

Does this have a name? Should this be avoided?

If so, how do you avoid such things (I guess in a similar way as you would avoid rivers)?

Edit: A LuaTeX implementation allowing to automate this would be welcome.

Addendum by Mico: I've added a bounty of 100 points to second Raphink's plea for a LuaTeX implementation of his idea.

Edit 2: I understand that fixing it automatically greatly increases time complexity since you need to do the analysis after the paragraph rendering, but the changes require to trigger a new paragraph rendering so it's a recursive process. What might be doable without increasing time complexity is to detect homeoarchies and highlight them (or underline them) using PDF annotations. I'd be quite happy with that already, as it would help to spot them and fix them manually afterwards.

Best Answer

One of Don Knuth's recommendations for fixing various typographical issues is to rewrite the passage in question – assuming that doing so is possible and/or permissible, of course. (The passage you cite is one case where you mustn't change a single word, obviously.) If you can't/mustn't rewrite the passage, you can still try to change some parameters such as the line width, font size, interword spacing, and occasionally impose a tie (unbreakable space), all in order to try to mitigate the problem.

Addendum: I've succeeded in reproducing the OP's text fragment in the following MWE:

\documentclass{article}
\usepackage[french]{babel}
\usepackage{kpfonts}
\begin{document}

\begin{minipage}{1.7in}
Je suis venu non pour juger le monde, mais pour sauver le monde. Celui qui me rejette
et qui ne re\c coit pas mes
\end{minipage}

\bigskip
\begin{minipage}{1.7in}
Je suis venu non pour juger~le monde, mais pour sauver le monde. Celui qui me rejette
et qui ne re\c coit pas mes
\end{minipage}

\bigskip
\begin{minipage}{1.6in}
Je suis venu non pour juger le monde, mais pour sauver le monde. Celui qui me rejette
et qui ne re\c coit pas mes
\end{minipage}

\bigskip
\begin{minipage}{1.8in}
Je suis venu non pour juger le monde, mais pour sauver le monde. Celui qui me rejette
et qui ne re\c coit pas mes
\end{minipage}
\end{document}

The first minipage reproduces the initial problem. In example two, I've inserted a tie between "juger" and "le": this forces a hyphenation of the word "juger" and succeeds in breaking up the repetition, at the cost of loose word spacing (given the narrow measure!). The second example does not impose a tie but shortens the measure, also breaking up the vertical word repetition a bit but also suffering from loose word spacing (esp in line 3). The fourth example widens the measure a bit; now lines 2 and 3 both start with "monde" (as opposed to "le monde" in the first example), and the interword spacing looks OK overall. A slight improvement, maybe, but really only very slight. I guess the problem to solve is particularly vexing because the repeated-word group contains two, rather than just one, word!

Related Question