2

Am I right that TeX processes text in a manner like this? Since the very first character it is forming an hbox of textwidth width. When the first hbox is filled in its width, TeX makes a hyphenation, adds this hbox to a vbox (for a paragraph) and starts to form the second hbox and so on. So the vbox is like a holder for several hbox'es (lines)? Is it like a vertical linked list of horizontal linked lists?

Below is an illustration of what I want to clarify. In the first line it makes an indent and hyphens as ma-chines. In the second one I tried to explicitly represent this. Does TeX do the same (ideologically)?

\documentclass{article}

\begin{document}
Computer science is the study of algorithmic processes, computational machines and computation itself.

\vbox{%
\hbox{\indent Computer science is the study of algorithmic processes, computational ma-}%
\hbox{chines and computation itself.}}
\end{document}

1 Answer 1

4

No TeX does not typeset line by line. Once a paragraph starts, horizontal mode is entered and the entire paragrah is set in a horizontal list (similar to an \hbox) then the entire paragraph is passed through a line breaking algorithm that does a least cost optimisation trying to minimise badness (actually, demerits) of the paragraph. The resulting sequence of hboxes and vertical glue and penaltiues is then added to a similarly infinite vertical list and later a similar but simpler algorithm splits a page off this main vertical list.

So the end result is similar to what you show but the timing is different.

1
  • So hyphening and line breaking does not interrupt the horizontal mode? It is like a sign of line breaking within the horizontal list?
    – Vladimir
    Oct 29, 2021 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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