A box's reference point

The following illustration of a generic box appears on p. 63 of the TeXbook:

What is a box's reference point in the following pathological cases?

1. The box has either (a) no width, or (b) no height and no depth, or (c) both a and b?

2. The box has a positive width and either a positive height or a positive depth (or both), which were not explicitly assigned but calculated automatically, and one of the following cases holds.

1. The box doesn't contain sub-boxes (but may contain other elements, e.g. glue)?
2. The box contains at least one sub-box, but some of the sub-boxes -- possibly all of them! -- is shifted to the left or to the right, or raised or lowered?
• Define reference point. For example, in \rotatebox, the reference point may be defined for the rotation. In general, the fact that \ht and \dp have TeX meaning implies that the baseline is a common reference point for all boxes. Multi-line boxes often use [t], [c], and [b] reference points, which have a specific defined meaning. Of course, any package-defined reference point has no relevance to "tex-core" – Steven B. Segletes Aug 31 '17 at 18:36
• @StevenB.Segletes: I'm just beginning learning about boxes. I've added to my post an illustration of a generic box, which shows it has a reference point. – Evan Aad Aug 31 '17 at 18:41
• The answer is where the left side of the box meets the baseline, I think, in all cases you mention. – Steven B. Segletes Aug 31 '17 at 18:42
• @StevenB.Segletes: And where does this occur in the situations I described? – Evan Aad Aug 31 '17 at 18:43
• Completely unrelated: Have you seen the youtube videos of Knuth explaining TeX in the early eighties? youtube.com/watch?v=C3vILM2cNuo More advanced videos follow up. – Johannes_B Sep 2 '17 at 16:35

Every box has height width and depth (any of which may be zero or negative) the reference point is by definition the point from which these lengths are measured. The box containing other boxes or not has no bearing on that.

Note that the height depth and width are assignable properties and need bear no relationship to the box contents.

If \box0 contains some content then after

\ht0=5pt
\dp0=6pt
\wd0=7pt


the height depth and width of box 0 will be 5pt 6pt and 7pt. In horizontal mode, the box will be positioned such that its reference point is placed at the current position, and the current position will move 7pt to the right (whatever the box contents). Similarly in vertical mode the box will be placed with baselineskip glue from the previous box calculated from the previous depth and the nominal 5pt height.

If you do not assign the box dimensions then they will be set depending on the box contents.

if set using \vbox the reference point of the box is at the left edge, at the vertical position of the last box in its content (with some details to be filled in if the last item is not a box or has over-large deoth)

If set using vtop the reference point is at the left edge at the height of the reference point of the first item of the content if it is a box, or at the top of the outer box otherwise.

For \vcenter it is a at the left edge of the box positined such that placing the reference point on teh baseline centres the box on the math axis.

• @EvanAad by definition it is at the left edge of the box \dp from the bottom and \ht from the top. If you have not explictly set those lengths as above then it depends how the box contents were assigned, and your question should be rather different, for example "what is the height of a box defined via \vtop as opposed to \vbox ?" – David Carlisle Aug 31 '17 at 18:55
• @EvanAad then in the example in your comment the answer is that the reference point is 1cm to the left of the reference point of the inner hbox, and with \vtop and \vbox it will be at the same vertical position as the reference point of the inner box, and with \vcenter it may be above or below the reference point of the inner box depending on that boxes height and depth – David Carlisle Aug 31 '17 at 19:03
• @EvanAad it is a property of the current horizontal or vertical list, that is the meaning of horizontal and vertical mode, in h-mode boxes are placed with there reference point at the current position, which then moves left by the width, in vertical mode boxes are placed with their reference point below the current position prefixed by glue of an amount depending on the depth of the last existing item on the list and the height of the box being added and \baselineskip and \lineskip lengths – David Carlisle Aug 31 '17 at 19:54
• the initial list is "the main vertical list" as the only relevant property of an empty list is its current point it doesn't really make sense to ask where that is, it is just the point at which any content will be added. – David Carlisle Aug 31 '17 at 20:01
• the default reference point for tex output is 1in from the top and 1in from the left of the page although pdftex allows that to be changed with \pdfhorigin and \pdfvorigin – David Carlisle Aug 31 '17 at 20:04

There are only a few ways to create boxes in TeX, and each of them has a well-defined notion of where the reference point ends up. See page 222 of The TeXbook (part of Chapter 21: Making Boxes):

Now let’s summarize all of the ways there are to specify boxes explicitly to TeX. (1) A character by itself makes a character box, in horizontal mode; this character is taken from the current font. (2) The commands \hrule and \vrule make rule boxes, as just explained. (3) Otherwise you can make hboxes and vboxes, which fall under the generic term ⟨box⟩. A ⟨box⟩ has one of the following seven forms:

\hbox⟨box specification⟩{⟨horizontal material⟩} (see Chapter 12)
\vbox⟨box specification⟩{⟨vertical material⟩} (see chapter 12)
\vtop⟨box specification⟩{⟨vertical material⟩} (see Chapter 12)
\box⟨register number⟩ (see Chapter 15)
\copy⟨register number⟩ (see Chapter 15)
\vsplit⟨register number⟩to⟨dimen⟩ (see Chapter 15)
\lastbox (see Chapter 21)

[…]

In math modes an additional type of box is available: \vcenter⟨box specification⟩{⟨vertical material⟩} (see Chapter 17).

For each of these, there is a well-defined procedure for where the reference point ends up, based on the reference points of its constituents. Characters from a font already come w.r.t. a reference point. For the others, it's best to see this in pictures (taken from A Beginner's Book of TeX's Chapter 8: Boxes, which I recommend reading):

While creating the box, you can specify the width to be positive or zero or negative (instead of letting TeX compute them from the things you put inside it). You can raise or lower boxes. You can explicitly assign the width or height or depth of a box, to change them. But in all cases the behaviour is predictable and well-defined, so the answer is just: the reference point is wherever you asked TeX to put it. :-) If you know how you made the box, you'll also know where its reference point is.