Context
Hi! I'm typesetting a table for a reference sheet I'm making where each row represents a probability distribution. For some rows (distributions), I've decided to put multiple formulas to show what they will look like for different parameters of the distribution.
Problem
My problem is... only some distributions have this multiple-interpretations-of-the-same-parameter conundrum, so only those distributions' rows need cells that span multiple columns (essentially, I'm wanting to "split" one cell in a table into multiple).
Attempted solution
Since my input is organised into a dictionary, and every distribution (row) which requires multi-column cell data is fed as an array, I am testing for this using a conditional and currently just using a grid inside the table cell. Observe:
#let distGridCreator(arr) = grid(
columns: (auto,) * arr.len(),
stroke: (right: 0.85pt),
inset: 5pt,
align: center + horizon,
[
#v(1fr) // So the grid.vline goes all the way to the top
#arr.first()
#v(1fr)
],
..arr.slice(1, -1),
grid.cell(stroke: (right: 0pt))[#arr.last()] // So the last item doesn't have a stroke on the right, the table cell's stroke should do
)
My current main dilemma is that if I use auto as my column dimensions (as above), then the grid cells get typeset quite nicely with every equation fitting inside as well, but if one of the equations is shorter than the others, then it gets "less" area, which is not what I want. I want all the cells of the grid to be of equal width, but if I use 1fr as the dimension for the columns, then they all get equal width, but the table cell does not get resized for the entire grid and the equations spill out if they are longer than the space they get allocated as per the division by the fractional length (1fr).
-# See pictures attached for visual of the difference between auto and 1fr.
Summary
Is there any way to make sure all the equations fit inside the grid cells, and to have the grid cells be equal width? One way I can think to do this is to measure the width of every grid cell, pick the largest, and then reassign all grid cell widths to be that maximum width, but I don't really know how to go about doing this. I'm all ears if someone has a more elegant solution!
Link
Typst webapp link: https://typst.app/project/rpe1lw6KKogw0bQUIGZ0vS