A vertical list of boxes.
| 1703 | self._set_glue(x, -1, total_shrink, "Underfull") |
| 1704 | |
| 1705 | class Vlist(List): |
| 1706 | """ |
| 1707 | A vertical list of boxes. |
| 1708 | """ |
| 1709 | def __init__(self, elements, h=0., m='additional'): |
| 1710 | List.__init__(self, elements) |
| 1711 | self.vpack() |
| 1712 | |
| 1713 | def vpack(self, h=0., m='additional', l=np.inf): |
| 1714 | """ |
| 1715 | The main duty of :meth:`vpack` is to compute the dimensions of |
| 1716 | the resulting boxes, and to adjust the glue if one of those |
| 1717 | dimensions is pre-specified. |
| 1718 | |
| 1719 | - *h*: specifies a height |
| 1720 | - *m*: is either 'exactly' or 'additional'. |
| 1721 | - *l*: a maximum height |
| 1722 | |
| 1723 | Thus, ``vpack(h, 'exactly')`` produces a box whose height is |
| 1724 | exactly *h*, while ``vpack(h, 'additional')`` yields a box |
| 1725 | whose height is the natural height plus *h*. The default |
| 1726 | values produce a box with the natural width. |
| 1727 | """ |
| 1728 | # I don't know why these get reset in TeX. Shift_amount is pretty |
| 1729 | # much useless if we do. |
| 1730 | # self.shift_amount = 0. |
| 1731 | w = 0. |
| 1732 | d = 0. |
| 1733 | x = 0. |
| 1734 | total_stretch = [0.] * 4 |
| 1735 | total_shrink = [0.] * 4 |
| 1736 | for p in self.children: |
| 1737 | if isinstance(p, Box): |
| 1738 | x += d + p.height |
| 1739 | d = p.depth |
| 1740 | if not np.isinf(p.width): |
| 1741 | s = getattr(p, 'shift_amount', 0.) |
| 1742 | w = max(w, p.width + s) |
| 1743 | elif isinstance(p, Glue): |
| 1744 | x += d |
| 1745 | d = 0. |
| 1746 | glue_spec = p.glue_spec |
| 1747 | x += glue_spec.width |
| 1748 | total_stretch[glue_spec.stretch_order] += glue_spec.stretch |
| 1749 | total_shrink[glue_spec.shrink_order] += glue_spec.shrink |
| 1750 | elif isinstance(p, Kern): |
| 1751 | x += d + p.width |
| 1752 | d = 0. |
| 1753 | elif isinstance(p, Char): |
| 1754 | raise RuntimeError("Internal mathtext error: Char node found in Vlist.") |
| 1755 | |
| 1756 | self.width = w |
| 1757 | if d > l: |
| 1758 | x += d - l |
| 1759 | self.depth = l |
| 1760 | else: |
| 1761 | self.depth = d |
| 1762 |