Plain TeX provides \centerline
for centering, well, lines of text, but nothing to center a paragraph. LaTeX has \centering
and the \center
environment. Looking at the LaTeX code, it appears very similar to what Bechtolsheim proffers in "TeX in Practice":
\rightskip = 1in plus 4em
\leftskip = \rightskip
\spaceskip = .3333em
\xspaceskip = .5em
\parfillskip = 0pt
\noindent
On the other hand there are sometimes cases where you want to have a
sequence of lines, all centered, but you do not want to make the line
breaking decisions all by yourself. So here is a sample where \TeX{}
did all the work.
\bye
Bechtolsheim also gives a begin/end environment-like example using this code.
A previous stackexchange question has similar code: A center environment for plain TeX
My question is why does Bechtolsheim recommend the use of \spaceskip
and \xspaceskip
and how did he come up with those numbers? Why do LaTeX (I believe) and the solution @egreg provides in the previous question eschew them?
Admittedly I don't fully understand \(x)spaceskip
so an explanation of them would be helpful.
p.s. I know the TUGboat and Amazon reviews of Bechtolsheim work (TeX in Practice) were only somewhat favorable, but I think the books are awesome. Yes, there are typographical and editing errors, but the content is great and I am finding the verbose examples extremely helpful and valuable. I would definitely encourage anyone who wants to learn the finer details of TeX to check them out. However, one should do at least a first reading of Knuth's "The TeX Book" first (dangerous bends being initially avoided), because Bechtolsheim does make some assumptions that the reader has a basic familiarity with TeX.
UPDATE: Great answer and comments. I think the ragged2e latex package documentation explains the issue quite well and points out that the Plain TeX version of ragged is in some ways superior to default LaTeX and attempts to fix it as well as the centering and raggedleft environments by essentially setting the fontdim2 value of a font (if available) to \spaceskip
which provides optimal spacing while preserving the ability to hyphenate which is unfortunately lost when fil
is used. I think a good Plain TeX implementation of centering, then should do something similar. It is also somewhat interesting that Schröder's package uses 2em
instead of Bechtolsheim's 4em
in the left/right skip registers.
\raggedright
.fil
for the left/right skip (Bechtolsheim uses4em
). Does thefil
make\(x)spaceskip
unnecessary then?