platformer / typst-algorithms

MIT License
135 stars 4 forks source link

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

Open platformer opened 1 year ago

platformer commented 1 year ago

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](https://github.com/platformer/typst-algorithms/assets/40146328/f7c364b5-300d-49ea-9281-c9896dc7d498)
platformer commented 1 year ago

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 https://github.com/typst/typst/issues/735.