andreasKroepelin / lovelace

A Typst package for typesetting pseudocode
MIT License
46 stars 4 forks source link

Split algorithm into multiple columns #11

Open acsor opened 3 months ago

acsor commented 3 months ago

I am currently writing a long algorithm using pseudocode-list wrapped inside a figure, and while allowing figure to break up into multiple pages works fine, I would also like to be able to split the pseudocode-list output up into two columns, so that it could fit within a single page. Is it possible doing this with the current version of lovelace? If not, could some option be added to make this possible?

andreasKroepelin commented 3 months ago

Hmm good question. Can a #grid be split into multiple columns?

acsor commented 3 months ago

Using grid was indeed one of my first thoughts. But then what about the numbering of lines in the algorithm? How would one continue it, even manually, to the second (or third) column? I have tried using 1. lists (aka enum) within pseudocode-list to manipulate the numbering, but I saw no change. I think It would instead be better if the numbering was managed internally by lovelace across multiple columns.

tingerrr commented 3 months ago

Using columns works reasonably well, which makes sense as that is its primary use case. But lovelace would need to internally do the column wrapping and do some necessary contextual calculations to get the size right. This way one could have a full spanning header with multiple columns of code.

Here's a contrived use case that already works, but would create a repeating header in all columns.

#import "@preview/lovelace:0.3.0"
#block(height: 100pt, columns(5, lovelace.pseudocode-list(title: [My Algorithm])[
  + AAA
  + AAA
  + AAA
  + AAA
  + AAA
  + AAA
  + AAA
  + AAA
]))

image