platformer/typst-algorithms

Indent guides extend beyond border when broken across pages and `inset` is smaller than `row-gutter`

platformer opened this issue · 1 comments

For both algo and code, if the figure is broken across pages and inset is smaller than row-gutter, indent guides will extend beyond the element's borders.

// push element to bottom of page

#code(
  row-gutter: 15pt,
  inset: 3pt,
  indent-guides: 1pt + black,
  breakable: true,
)[
  ```py
  def floyd_warshall(G):
    # let G be an adjacency matrix
    dist = G
    
    for k in range(len(G)):
      for i in range(len(G)):
        for j in range(len(G)):
          if dist[i][j] > dist[i][k] + dist[k][j]:
            dist[i][j] = dist[i][k] + dist[k][j]
    
    return dist
  ```
]

image

The reason this issue occurs is that indent guides extend by row-gutter / 2 in both directions. However, when a block is broken across pages, the padding next to the pagebreak is determined by the block's inset.

This issue has an experimental solution in https://github.com/platformer/typst-algorithms/tree/tablex, but there are various bugs that prevent this branch from being merged.

This issue is pretty low priority since it's unlikely for a user to want to typeset breakable figures anyway. Though resolving this issue could make this package a viable option for typesetting entire programs with Typst.

Potentially related to typst/typst#735.