3

I have a \vtop box spreading to 40pt. The box does spread according to the actual text more than 40pt.
Question is: Where and how may I get the value of the spread that is done by TeX to the first box?

Please do not bother with the \hsize.

\raggedright
\newdimen\firstboxvalue
\hbox{
\vtop{\hsize=80pt This is the text that will fill all of the boxes. This is the text that will fill all of the boxes This is the text that will fill all of the boxes This is the text that will fill all of the boxes This is the text that will fill all of the boxes This is the text that will fill all of the boxes \vskip\baselineskip\hrule width\hsize}
**%\firstboxvalue=?? <question**
\vtop spread \firstboxvalue{\hsize=80pt  This is the text that will fill all of the boxes This is the text that will fill all of the boxes This is the text that will fill all of th text that will fill all of the boxes \vfill \vskip\baselineskip \hrule width\hsize}}
\bye

2 Answers 2

1

If I understand the question you want to remove the fill from the end and spread the lines, but perhaps you just want the space at the end as in the last example

enter image description here

\raggedright \newdimen\firstboxvalue
\hbox{%

\vtop{\hsize=80pt This is
    the text that will fill all of the boxes. This is the text that
    will fill all of the boxes This is the text that will fill all of
    the boxes This is the text that will fill all of the boxes This is
    the text that will fill all of the boxes This is the text that
    will fill all of the boxes \vskip\baselineskip\hrule width\hsize}%
\setbox0\lastbox
\copy0\ %
  
\vtop spread \firstboxvalue{\hsize=80pt This is the text that will
    fill all of the boxes This is the text that will fill all of the
    boxes This is the text that will fill all of th text that will
    fill all of the boxes \vfill \vskip\baselineskip \hrule
    width\hsize}


\vtop to \dp0{\hsize=80pt \baselineskip=12pt plus 1 fil
    This is the text that will
    fill all of the boxes This is the text that will fill all of the
    boxes This is the text that will fill all of th text that will
    fill all of the boxes  \vskip\baselineskip \hrule
    width\hsize}

\vtop to \dp0 {\hsize=80pt This is the text that will
    fill all of the boxes This is the text that will fill all of the
    boxes This is the text that will fill all of th text that will
    fill all of the boxes \vfill \vskip\baselineskip \hrule
    width\hsize}



} 

\bye

5
  • Thanks. So, \firstboxvalue should be equal to \dp0 ? Works. I did not want to stretch the text vertically, as you did in column 3, but it's a nice feature.
    – user284656
    Nov 12, 2022 at 23:55
  • @user284656 but you want to not stretch as stretch is additional length over the natural size not the final size Nov 13, 2022 at 0:41
  • "What is puzzeling me.." There seems to be no way to give the boxes a limited size. If one says "spread" or "to", they spread.
    – user284656
    Nov 13, 2022 at 1:49
  • @user284656 I can not guess what you mean by limited size here. Are you looking for \vsplit to discard any content past the spcified size??? Nov 13, 2022 at 9:51
  • Ok, it is solved, because I now know, how to get the values. Next question.
    – user284656
    Nov 13, 2022 at 20:51
1

I think you're misunderstanding spread. If I do

\setbox0=\vtop{ABC\par DEF}
\showthe\ht0
\showthe\dp0

\setbox0=\vtop spread 40pt {ABC\par\vss DEF}
\showthe\ht0
\showthe\dp0

I get

> 6.83331pt.
l.2 \showthe\ht0

?
> 12.0pt.
l.3 \showthe\dp0

?
> 6.83331pt.
l.6 \showthe\ht0

?
> 52.0pt.
l.7 \showthe\dp0

The height of the first box is the same as the height of the top line. The rest goes in the depth (this is how \vtop works). Then spread 40pt adds 40pt to the total height plus depth, but doesn't change the reference point, that stays at the baseline of the first item in the \vtop.

If I change spread 40pt into to 40pt, I get

> 6.83331pt.
l.2 \showthe\ht0

?
> 12.0pt.
l.3 \showthe\dp0

?
> 6.83331pt.
l.6 \showthe\ht0

?
> 33.16669pt.
l.7 \showthe\dp0

so you see that the total height plus depth is exactly 40pt.

If you want the final rules to be aligned, you want first to ensure the top lines have the same height; with standard text, \strut is enough. See what happens if you omit it in the second example.

You need to measure the first box (or both, if the second one has larger natural height plus depth than the first one.

\newdimen\firstboxvalue

\raggedright

\setbox0=\vtop{\hsize=80pt 
  \strut
  This is the text that will fill all of the boxes.
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  \vskip\baselineskip\hrule
}
\firstboxvalue=\ht0 \advance\firstboxvalue by \dp0
\noindent
\box0\ \vtop to \firstboxvalue{\hsize=80pt
  \strut
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  This is the text that will fill all of th text
  that will fill all of the boxes
  \vfill
  \vskip\baselineskip \hrule width\hsize}

\bigskip

\setbox0=\vtop{\hsize=80pt
  aaaaaaaa
  This is the text that will fill all of the boxes.
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  \vskip\baselineskip\hrule
}
\firstboxvalue=\ht0 \advance\firstboxvalue by \dp0
\noindent
\box0\ \vtop to \firstboxvalue{\hsize=80pt
  This is the text that will fill all of the boxes
  This is the text that will fill all of the boxes
  This is the text that will fill all of th text
  that will fill all of the boxes
  \vfill
  \vskip\baselineskip \hrule width\hsize}

\bye

enter image description here

Do you see the problem in the second example? The top lines have different height (because the first line in the first box has no ascenders).

Adding \strut also in the second example gives

enter image description here

3
  • Thanks But not clear. In this example: If I add more text, the vboxes spread vertically and they are never 40pts high unless you insert a 40pt text. You have added the line "aaaaaaaa" to show, that another line changes the height of the box. That was the question: The next box should copy the height of the first or previous box, even if it has lesser text or more.
    – user284656
    Nov 13, 2022 at 1:36
  • @user284656 Sorry, but your question is quite unclear, in the light of your comment here. Can you please try and explain better the -roblem you’re facing?
    – egreg
    Nov 13, 2022 at 9:37
  • Ok, it is solved, because I now know, how to get the values. Next question.
    – user284656
    Nov 13, 2022 at 20:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .