11

Exercise 12.8
Assume that \box1 is 1 pt high, 1 pt deep, and 1 pt wide; \box2 is 2 pt high, 2 pt deep, and 2 pt wide. A third box is formed by saying

\setbox3=\hbox to3pt{\hfil\lower3pt\box1\hskip-3pt plus3fil\box2}

What are the height, depth, and width of \box3? Describe the position of the reference points of boxes 1 and 2 with respect to the reference point of box 3.

Answer
\box3 is 2 pt high, 4 pt deep, 3 pt wide. Starting at the reference point of \box3, go right .75 pt and down 3 pt to reach the reference point of \box1; or go right 1 pt to reach the reference point of \box2.


enter image description here

I don't understand the reference-point part of this question and need an explanation. I expected a different answer: "go down 3 pt to reach the reference point of \box1; or go left 2 pt to reach the reference point of \box2". The negative glue, \hskip-3pt plus1fil, I believe, is the cause of my confusion.


Why do \hbox to3pt{\box1\box2} and \hbox to3pt{\box1\hskip-3pt plus1fil\box2} yield identical results, but \hbox to3pt{\box1\hskip-3pt\box2} move it 3 pt to the left and \hbox to3pt{\box1\hskip3pt plus1fil\box2} move \box2 3 pt to the right? (attempt to highlight and ask about the effect of the plus1fil component with regard to negative and positive skips)

9

With \lower3pt\box1, the original reference point is moved down 3pt; the box will have height 0pt, depth 4pt and width 1pt.

The vertical position of the reference points is thus clear.

Let's analyze the horizontal position.

The space to fill is 3pt and we are given

  1. infinite glue with 0pt natural width and 1fil as stretchability;
  2. a 1pt wide box;
  3. flexible glue with -3pt natural width and 3fil as stretchability;
  4. a 2pt wide box.

The computed natural width is 0pt, so less than the stated width to fill up. The total amount of stretching is 4fil, so the stretch ratio is computed to be 0.75 (for fil). But the -3pt of natural width is still considered.

The natural width is 0pt, so the infinite glues have to get in the game. The 3pt is divided into four parts, one assigned to the first glue and three to the second. Since 3/4=0.75, the reference point of the first box will be 0.75pt right of the reference point of the outer box.

Then comes the second glue, with its -3pt plus 3fil, which is turned into glue

-3pt + 0.75*3pt = -0.75pt

(see the top dangerous bend at page 77). We have moved (0.75+1)pt, so the reference point of \box2 is at 1pt from the reference point of the outer box.

If you do \showbox3, where \box1 and \box2 are empty boxes manually set to the required dimensions, you get

> \box3=
\hbox(2.0+4.0)x3.0, glue set 0.75fil
.\glue 0.0 plus 1.0fil
.\hbox(1.0+1.0)x1.0, shifted 3.0
.\glue -3.0 plus 3.0fil
.\hbox(2.0+2.0)x2.0

(if \raise3pt had been used, you'd get shifted -3.0). The glue can be computed with the stretch ratio 0.75 (for fil units): the first glob becomes 0.75, the second glob -3+3*0.75 (pt unit are implied).

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.