Is it possible to split content across grid columns?

hi! We use a typst template with Quarto that works beautifully for 3 equal-sized columns. I understand that if we want the columns to be different widths we need to use a grid instead, but for the life of me I can’t figure out how to make the content of the Quarto document pour into the grid columns the way they do with the actual columns function.

Here is what I’ve tried in typst-template.typ

show: grid.with( 
    columns: (1fr, 2fr, 1fr),
    inset: 5pt,
    rows: (auto),
    stroke: (paint: blue, thickness: 1pt, dash: "dashed”),  // just to visualize the columns
    gutter: 55pt
  )

  set par(justify: true, first-line-indent: 0em)
  show par: set par(spacing: 0.5em)

  content

but the resulting output has the left-most column populated across multiple pages with the middle and right columns empty. I know that content can’t be spread, but then I’m stuck. Is this possible?

Many thanks for any assistance!

Hello!

Typst does not support this, there is an open feature request in #1469 to allow specifying widths for columns and #6060 to allow content to flow across containers.

The only solution that comes to mind is to use the meander package. If multiple pages need to be supported, I think a recursive custom reflow overflow would be needed. However, that is explicitly discouraged in the docs and it breaks for long documents because of the maximum recursion depth.

2 Likes

Thank you so much! I’d never heard of the meander package and you’re right that this does what I need! (Also, just to clarify, I definitely do not want multiple pages as this is an academic poster; so that’s not a concern.)

This solution is slightly more temperamental than the columns function (it can’t hold gt tables, I can’t use colbreak()), but as long as I stick to markdown, r code chunks, and python code chunks everything compiles fine and looks perfect. Thank you again!

Here’s what I ended up putting in my template:


  // flow content into 3 column layout
  meander.reflow({
    import meander: *

    container(width: 25%, height: 85%)
    container(align: center, width: 45%, height: 85%)
    container(align: right, width: 25%, height: 85%)

    content[
      #text(content)
    ]

  })

To show code snippets, use typc and not typ.

Same goes to the OP.

Glad to hear that Meander did the trick. If you have time, don’t hesitate to open an issue listing the kinds of content that you couldn’t get in or didn’t split properly, or in general any difficulty you encountered. There are definitely bugs and unhandled element kinds in Meander’s content bisection algorithm, and I’m always looking for new test cases.

Also I’m not sure which version of Meander you used, but the latest one supports colbreak() and colfill() to skip directly to the next column.