How to set the width of lq.diagram to 100%

I’m trying to figure out how to set the width of a graph to 100% when using lilaq to draw it. I’ve attempted to do this using the layout keyword, as shown in the example code below, but the graph is overflowing to the right, beyond the available width.

Is there a good way to set the width of lq.diagram to 100%?


#import "@preview/lilaq:0.4.0" as lq
#set page(paper: "a4")

= Figure
#block(
  width: 100%,
  layout(size => {
    lq.diagram(
      width: size.width,
      height: 5cm,
      lq.plot(range(8), (3, 6, 2, 6, 5, 9, 0, 4), smooth: true)
    )
  })
)

= Table
#table(
  columns: (1fr, 1fr, 1fr, 1fr, 1fr),
  inset: 10pt,
  align: horizon,
  table.header(
    [], [*A*], [*B*], [*C*], [*D*]
  ),
  [row 1],
  [],[],[],[],
  [row 2],
  [],[],[],[],
)

Hi! width: 100% should just work.
This is a bug of lilaq. Fortunately, it was fixed last month (merged on 2025-07-30), but the patch haven’t been released yet.

2 Likes

Got it, thanks! Using the code from the main branch on GitHub fixed the problem. Really appreciate your help!

1 Like

Note from the author of Lilaq: This was not a bug. Sizing according to the parent was simply not supported and it was a huge effort to change that (due to the dynamic space that axes, titles and so on occupy). In the next version (which I expect to release soon) this will be included.

5 Likes