add tag
UdiB
I want to typeset a framebox with plainTeX. The box should be 3.375in wide × 2.125in high, and I want 4 rules to mark its border (with `hrule` and `vrule`).

I tried by I get a box which is as wide at the textwidth of the document and an `overfull hbox` warning. Why?

```
% !TEX TS-program = luatex
\synctex=0
\newdimen\cardwidth \cardwidth3.375in
\newdimen\cardheight \cardheight2.125in

\hbox to\cardwidth{\parindent0pt%
  \vrule \vbox to \cardheight{\hrule%
  some text\par goes here\vfil\hrule%
  }%
\vrule
}
\bye
```

![Untitled.png](/image?hash=cb50c7f54f22bbcd454edd1b946cb46390155e8a17f0fb66a5f3f35885b1856e)
Top Answer
frougon
The problem is that the width of your `\vbox` is determined by the `\hsize` parameter, whose value comes from the default set in plain.tex (`\hsize=6.5in`). Set `\hsize` inside the `\vbox` so that it accounts for the width of the two vertical rules and you're done.

In addition to this:

 - I moved the `\parindent` assignment where it is really needed;
 
 - I intentionally left a space token after every physical unit keyword (`in`, `pt`, etc.) occuring in TeX assignments (see the note below);
 
 - I replaced `\hbox to \cardwidth` with `\hbox` because the width of this `\hbox` is already determined by its contents (it does work with `\hbox to \cardwidth`; simply, that would be “overconstrained”).
 
You can check the precise box measures by uncommenting the line containing `\tracingoutput=1 \tracingonline=1` (the lengths are given in `pt`; your `\cardwidth` and `\cardheight` include the rule widths).

![Screenshot_2024-07-22_16-59-23.png](/image?hash=923f012ed8a084ec680e70d0d62463d7b98b5a8e6aa688d7063fc129c7445733)
 
```
\newdimen\cardwidth
\newdimen\cardheight

\cardheight 2.125in
\cardwidth 3.375in

% May be helpful: \tracingoutput=1 \tracingonline=1

\hbox{%
  \vrule
  \vbox to \cardheight {%
    \hsize=\dimexpr \cardwidth - 0.4pt*2\relax
    \parindent=0pt
    \hrule
    some text\par
    goes here\vfil
    \hrule
  }%
  \vrule
}

\bye
```
 
# Note

The idea behind the space token I leave after every physical unit keyword occuring in a TeX assignment, besides improving readability, is to prevent, for instance, `\foo = 3in\bar` resulting in a breakage should the beginning of the expansion of `\bar` ever expand to x and `inx` be an existing physical unit keyword in some hypothetical future release of TeX (!). The grammar displayed on TeXbook p. 270 has been tailored for this: it shows that TeX always reads ⟨one optional space⟩ after a ⟨physical unit⟩ in the production rules for ⟨unit of measure⟩.

# Another note (on `\topskip` and glue setting in boxes)

Using `\tracingoutput=1 \tracingonline=1`, you can see that `\topskip` is set to `0pt` according to TeXbook pp. 113-114:

```
.\vbox(643.20255+0.0)x243.91124, glue set 489.6288fill
..\glue(\topskip) 0.0
..\hbox(153.57375+0.0)x243.91124
...\rule(*+*)x0.4
...\vbox(153.57375+0.0)x243.11125, glue set 132.67853fil []
...\rule(*+*)x0.4
..\glue 0.0 plus 1.0fill
```

This is fine and expected, because your `\hbox` is the first box in the page body and its height is `153.57375pt`, which is more than `10pt` (plain.tex sets `\topskip=10pt`).

The only glue item that stretches in the tall `\vbox` that corresponds to the page body:

```
\vbox(643.20255+0.0)x243.91124, glue set 489.6288fill
```

is its final item, namely `\glue 0.0 plus 1.0fill` (it comes from `\bye`, defined with `\outer\def\bye{\par\vfill\supereject\end}`). The stretching is performed on the highest-order component that doesn't “cancel out” considering all glue items in the box, i.e. `fill` here (cf. TeXbook p. 77). The glue setting corresponding to the above `glue set 489.6288fill` diagnostic message does provide the needed amount of space in the vertical direction:

489.6288 × 1.0 = 489.6288 = 643.20255 - 153.57375.

I'm so relieved! :)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.