April 11, 2023

LaTeX and the Knuth plass algorithm

 In the past many attempts were made to compare LaTeX with MS Word. On the first look the comparison is a subjective one, that means person1 likes MS word while person2 not. To judge on a more rational basis, it has to be defined first what the goal in typography is. The hidden goal is to create justified text which is the opposite of left alignment.

If the goal is only to provide left-align text the output of LaTeX and MS Word is the same. At the end of each line there is a white gap which is fluctuating. Such a text can be read easily and it also easy going to program a software to format such a text. Nearly all word processors are able to do so. In contrast, if the objective is to produce fully justified text, a certain word processor will come to its limit.

The goal in typography in general and in LaTeX in detail is to realize a certain sort of formatting which is known as difficult to realize. For the same task "produce justified paragraph" it is possible to judge about different programs like MS Word, LaTeX, indesign and so on. LaTeX is known for its strength in this single use case.

In contrast, possible alternatives over LaTeX like MS Word, Libreoffice, the fpdf2 library or an ascii text editor are not able to produce high quality justified text. These programs were programmed to typeset only left aligned text. In other words, if the idea is to write a LaTeX replacement from scratch, then the software needs the feature to produce justified text with ease.

Let us go a step backward. The most advanced challenge in typography is to produced justified text. Such a goal was hard to realize for metal based typography before the advent of the computer and it is also hard for modern software programs. In contrast, left justified text are much easier to realize. All what the software has to do is to put the characters next to each other with the same white space between the words. Writing a computer program or a library which is able to do so is an easy task.

In other words, the self understanding of LaTeX is to master the hardest topic within typography. And comparing LaTeX with other programs makes only sense for this single problem. So it is not about putting glyphs to a sheet of paper in general but in the context of a certain arrangement.

The interesting situation is, that 9/10 people will agree that LaTeX capabilities in creating justified paragraph is better than the Word ability to do so. Because this task can be measured on an objective basis. Such a benchmark doesn't explain why it is important to format text in this way. It is mostly a non practical challenge with the attempt to investigate if a certain book printer or a typesetting software is mastering the complicated problems.

It should be mentioned that programs like MS Word, Webbrowsers and text editors are never claiming that they can master this problem. For example the MS Word software has the left-aligned paragraph as the default setting for every new document. In contrast, the LaTeX software is using justified text as default. This is a hint what the self understanding of the program is. In other words, LaTeX assumes, that a book or a journal should be typesetted only in justified mode and no alternative is allowed.