TeX Core – Understanding Boxes at the Primitive Level in TeX

boxestex-core

I'm learning plain TeX as a nerdy hobby. My current project involves trying to divide the page into unequal columns. I only want to use boxes and glue, with no external dependencies, e.g. eplain. Before diving the page I wanted to learn how to frame a box, to assist my learning through visualisation. My attempt to visualise the writing area i.e. vsize and hsize produced an overfull hbox. My minimal working example is:

\hrule
\hbox to \hsize{
  \vrule
  \vbox to \vsize{
    \vfill
    \hfill
  }
  \vrule
}
\hrule
\bye

The output was:

Overfull \hbox (5.24442pt too wide) detected at line 9
Overfull \vbox (10.4pt too high)

Can someone please explain to me what is causing the boxes to overflow given that I am only using glue. My hunch is that I am placing my box inside an existing "default" box, which it is overflowing.

I am using ubuntu 22.04 and pdftex --version outputs the following:

pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2022/dev/Debian)
kpathsea version 6.3.4/dev
Copyright 2021 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.03

Thanks.

Best Answer

Your \hbox to\hsize includes space from the the end of line 2, \vrule (width 0.4pt), \vbox (width \hsize because of \hfill inside it), space from the end of line 7, \vrule (width 0.4pt). The sum of this material has its width greater than \hsize by 5.24442pt.

The height of this box is equal to height of \vbox inside it. The first \hrule is inserted to the first baseline (its distance is \topskip=10pt for the upper boundary of the \box255 propagated to the output routine. Then there is the box of \vsize height and then the second \hrule (0.4pt). So the \box255 has its height: 10pt+\vsize+0.4pt. So, the output routine reports \vbox 10.4pt too high.

Related Question