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.

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.

share|improve this question
    
I don't know if there's a name other than "repetition"; of course it should be avoided whenever possible, also at end-of-line: it may confuse the reader. –  egreg Sep 5 '11 at 20:19
7  
Use a tie, for example juger~le; in case the text is unmodifiable, there's little you can do if this doesn't work other than trying in other places. If a paragraph is long, almost any space far enough from the start is usually a feasible line break point. If the text is modifiable, go on and change it; I often say that it's rather uncommon that one's prose is perfect at first writing and that correcting bad line breaks can help polishing it. –  egreg Sep 5 '11 at 20:29
4  
The error this can lead to does have a name: homeoarchy is when a copyist (or, by extension, a reader) misses out a line because the start of two lines being similar. –  mas Sep 6 '11 at 7:53
4  
I don't think this can be solved without changing the line breaking algorithm or getting suboptimal results. Imagine having two bad lines 6 and 7, line 6 could be changed by a different breaking in line 5 and line 7 could stay the same. This (I am still tired now) I believe cannot be solved using the dynamic programming approach Knuth & Plass are using thus resulting in a higher time complexity. –  topskip Sep 14 '11 at 7:48
1  
@Raphink correct - but even then you possibly could get better results if you chose another breakpoint but this would require a different line breaking algorithm (that's what the linebreak_filter in LuaTeX is for :)) –  topskip Sep 14 '11 at 8:32
show 2 more comments

2 Answers 2

up vote 12 down vote accepted

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!

share|improve this answer
    
Where does Knuth discuss this? –  N.N. Sep 6 '11 at 6:55
3  
@N.N. There's the index entry "bad breaks, avoiding" in the TeXbook; there's also a quotation from GB Shaw on page 107. –  egreg Sep 6 '11 at 8:37
1  
@Mico: in your example you inserted a tie between "juger" and "le monde". Another solution is to insert a tie between "sauver" and "le monde". The result is similar, but it looks nicer imo. –  ℝaphink Sep 10 '11 at 22:30
1  
I've edited the question to ask for a LuaTeX automated implementation if possible. I think storing the first word of every line and comparing it with the first word of every new line, adding a tie when it's identical, could work, and I'm pretty sure @Patrick would be happy to have a go at that :-) –  ℝaphink Sep 13 '11 at 22:06
1  
@Mico: I added an answer wich provides an automated way to detect homeoarchies. I've already fixed about 30 of them on a book of mine using the code. –  ℝaphink Sep 19 '11 at 15:03
show 4 more comments

I've added an homeoarchy option to the development version of the impnattypo package which adds detection for homeoarchies. It doesn't fix them since as Patrick mentioned, it would increase the time complexity too much.

The result is the following:

detected homeoarchy in example

I've ran it on a 150+ pages book and it found quite a few of them.

Edit: The latest version on github is now able to detect homoioteleutons (the same thing, at the end of lines) as well, so the following:

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

\usepackage[homeoarchy, draft,
            homeoarchywordcolor=green,
            homeoarchycharcolor=blue,
            homeoarchymaxwords=2,
            homeoarchymaxchars=1]{impnattypo}

\begin{document}

\section{Testing homeoarchy detection}
\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}

\section{Testing homoioteleuton detection}
\begin{minipage}{1.7in}
\parindent=2cm
\indent 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}

produces:

full detection

and again this had helped me find quite a few of them in my books.

share|improve this answer
1  
Great job! To keep the time complexity down while updating the spacing automatically, you could have an auxiliary file (I'd say, not the .aux file) with the info on what to tweak from previous runs, and only compute for changed paragraphs (perhaps with some md5 sum business?) or new paragraphs. –  Bruno Le Floch Sep 20 '11 at 0:29
2  
@Bruno: I see what you mean. However, from fixing quite a few of these mistakes in books lately, I can tell that fixing it automatically would not really be a good idea. It is sometimes as simple as inserting a tie before the second matching word, but it can often be more complex, especially since fixing an homoioteleuton can lead to generating an homeoarchy, and fixing both introduces overfull lines since you add a lot of ties... So it's probably a better idea to keep it to the detection level. –  ℝaphink Sep 20 '11 at 6:34
add comment

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.