A vertical list of boxes.
| 1421 | |
| 1422 | |
| 1423 | class Vlist(List): |
| 1424 | """A vertical list of boxes.""" |
| 1425 | |
| 1426 | def __init__(self, elements: T.Sequence[Node], h: float = 0.0, |
| 1427 | m: T.Literal['additional', 'exactly'] = 'additional'): |
| 1428 | super().__init__(elements) |
| 1429 | self.vpack(h=h, m=m) |
| 1430 | |
| 1431 | def is_char_node(self) -> bool: |
| 1432 | # See description in Node.is_char_node. |
| 1433 | return False |
| 1434 | |
| 1435 | def vpack(self, h: float = 0.0, |
| 1436 | m: T.Literal['additional', 'exactly'] = 'additional', |
| 1437 | l: float = np.inf) -> None: |
| 1438 | """ |
| 1439 | Compute the dimensions of the resulting boxes, and to adjust the glue |
| 1440 | if one of those dimensions is pre-specified. |
| 1441 | |
| 1442 | Parameters |
| 1443 | ---------- |
| 1444 | h : float, default: 0 |
| 1445 | A height. |
| 1446 | m : {'exactly', 'additional'}, default: 'additional' |
| 1447 | Whether to produce a box whose height is 'exactly' *h*; or a box |
| 1448 | with the natural height of the contents, plus *h* ('additional'). |
| 1449 | l : float, default: np.inf |
| 1450 | The maximum height. |
| 1451 | |
| 1452 | Notes |
| 1453 | ----- |
| 1454 | The defaults produce a box with the natural height of the contents. |
| 1455 | """ |
| 1456 | # I don't know why these get reset in TeX. Shift_amount is pretty |
| 1457 | # much useless if we do. |
| 1458 | # self.shift_amount = 0. |
| 1459 | w = 0. |
| 1460 | d = 0. |
| 1461 | x = 0. |
| 1462 | total_stretch = [0.] * 4 |
| 1463 | total_shrink = [0.] * 4 |
| 1464 | for p in self.children: |
| 1465 | if isinstance(p, Box): |
| 1466 | x += d + p.height |
| 1467 | d = p.depth |
| 1468 | if not np.isinf(p.width): |
| 1469 | s = getattr(p, 'shift_amount', 0.) |
| 1470 | w = max(w, p.width + s) |
| 1471 | elif isinstance(p, Glue): |
| 1472 | x += d |
| 1473 | d = 0. |
| 1474 | glue_spec = p.glue_spec |
| 1475 | x += glue_spec.width |
| 1476 | total_stretch[glue_spec.stretch_order] += glue_spec.stretch |
| 1477 | total_shrink[glue_spec.shrink_order] += glue_spec.shrink |
| 1478 | elif isinstance(p, Kern): |
| 1479 | x += d + p.width |
| 1480 | d = 0. |
no outgoing calls
no test coverage detected
searching dependent graphs…