关于扩展 vbox 及其尺寸

关于扩展 vbox 及其尺寸

我有一个 \vtop 框,其展开范围为 40pt。根据实际文本,该框的展开范围确实超过 40pt。
问题是:我在哪里以及如何获取 TeX 对第一个框进行的展开值?

请不要为 \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

答案1

如果我理解了这个问题,你想从末尾删除填充并展开线条,但也许你只是想要末尾的空间,就像最后一个例子一样

在此处输入图片描述

\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

答案2

我想你误会了spread。如果我这样做

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

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

我明白了

> 6.83331pt.
l.2 \showthe\ht0

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

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

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

第一个框的高度与顶线的高度相同。其余部分位于深度中(这就是\vtop工作原理)。然后spread 40pt 添加40pt 为总高度加上深度,但不改变参考点,即停留在 中第一个项目的基线处\vtop

如果我换成spread 40ptto 40pt我得到

> 6.83331pt.
l.2 \showthe\ht0

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

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

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

所以你会看到总高度加上深度正好是 40pt。

如果希望最终规则对齐,首先要确保顶行具有相同的高度;使用标准文本\strut就足够了。看看如果在第二个示例中省略它会发生什么。

您需要测量第一个箱子(或两个箱子,如果第二个箱子的自然高度和深度比第一个箱子大)。

\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

在此处输入图片描述

你看到第二个例子中的问题了吗?顶部的线条有不同的高度(因为第一个框中的第一条线没有上升部分)。

\strut在第二个例子中也添加

在此处输入图片描述

相关内容