How to change diagram font in lilaq

Hi all,

I started experimenting lilaq, which is amazing. I am sure that this package will have a bright future.

For the moment, I am facing an issue that I dontm’t know to solve. I don’t know whether it is a bug or a feature that is not implemented yet.

Following the documentation of lilaq, I tried

#show: lq.set-diagram(width: 10cm)
#show lq.selector(lq.diagram): set text(0.8em)

which works as expected.

So, I tried to expand these commands a bit to change the width and the font of the diagram:

#show: lq.set-diagram(width: 90%)
#show lq.selector(lq.diagram): set text(font: "Lato")

Unfortunately, the resulting diagram remains unaffected by these commands.

My questions are : Is it the right way for doing this ? Is it the expected behavior or not ? Is there a workaround ?

Thank you for your help

Hi @maucejo ,

If I was you, I would try both lines of code independently.

Font
If you comment the first line of code, to leave only the one changing the font, that should work (assuming you have the font named “Lato” available for the compiler to use.

Width
Regarding the width: 90%, it triggers the following:

assertion failed: field ‘width’ of element ‘diagram’: expected length, found ratio

Which is what is expected for the width parameter as it can only accept a length (and not a ratio). In other words, it works as designed. See diagram − Lilaq.

1 Like

Hi @maucejo ,

passing a ratio to diagram.width will be possible starting with lilaq:0.5.0, I implemented this here last week.

The text set rule should just work fine (check it out by adding a diagram.title for instance). Note that Lilaq uses Zero for displaying tick labels on axes, so the math font is actually used here! Either you need to use a math font or tell Zero, not to use math for its number formatting by setting math: false via

#import "@preview/zero:0.4.0": set-num
#set-num(math: false)
3 Likes

A workaround until lilaq:0.5.0

#import "@preview/lilaq:0.4.0" as lq

// Keep only diagram data area for tests
#let diagram = lq.diagram(xaxis: none, yaxis: none)

#let scale-width(ratio, body) = {
  layout(size => {
    let (height, width) = measure(diagram)
    show: lq.set-diagram(width: width * ratio)
    diagram
  })
}

#diagram
#scale-width(100%, diagram)
#scale-width(80%, diagram)
#scale-width(50%, diagram)

Note that the end product with axis and titles, etc. won’t reflect the “real” width ratio as code calculates the width of the whole diagram, as opposed to the width of the data area.

width
The width of the diagram’s data area (excluding axes, labels etc.).

1 Like

Thank you @vmartel08 and @Mc-Zen for your answers. I can’t mark both your answers as solution, but they are.

Please mark one of them as a solution so your post appears as solved. Thanks!

Done @PgBiel ! :slight_smile: Thank you all for your help.

1 Like