typst-pinit icon indicating copy to clipboard operation
typst-pinit copied to clipboard

Highlighting inside an non-top-aligned block is broken with typst latest compiler

Open maugier opened this issue 1 year ago • 1 comments

Hello,

This example (where pinit-highlight-equation-from is taken from the reference website) used to work fine with typst v0.11.1:

#import "@preview/pinit:0.2.0": *
#import "@preview/touying:0.5.2": themes


#show: themes.university.university-theme

#let pinit-highlight-equation-from(height: 2em, pos: bottom, fill: rgb(0, 180, 255), highlight-pins, point-pin, body) = {
  pinit-highlight(..highlight-pins, dy: -1em, fill: rgb(..fill.components().slice(0, -1), 40))
  pinit-point-from(
    fill: fill, pin-dx: 0em, pin-dy: if pos == bottom { 0.8em } else { -0.6em }, body-dx: 0pt, body-dy: if pos == bottom { -1.7em } else { -1.6em }, offset-dx: 0em, offset-dy: if pos == bottom { 0.8em + height } else { -0.6em - height },
    point-pin,
    rect(
      inset: 0.5em,
      stroke: (bottom: 0.12em + fill),
      {
        set text(fill: fill)
        body
      }
    )
  )
}

== CVSS

#align(horizon, block[
Exemple: #pin(1)CVSS:3.1#pin(2)/#pin(3)AC:H#pin(4)/#pin(5)AV:N#pin(6)x
])

#pinit-highlight-equation-from((1,2), (1,2), pos: bottom, height: 5em, fill: red, [Version])
#pinit-highlight-equation-from((3,4), (3,4), pos: top, height: 5em, fill: yellow, [Complexité: Haute])
#pinit-highlight-equation-from((5,6), (5,6), pos: bottom, height: 4em, fill: blue, [Vecteur: Network])

typst-good

Starting from this specific commit, typst renders it like this:

https://github.com/typst/typst/commit/a52987a8c26bc13e3db4cc300b8cd9d81eb8a18d

typst-bad

It also throws several errors in cetz regarding multiple deprecated usages of measure() with style arguments

The code works correctly when it is align(top) instead of align(horizon).

Thanks for the great work !

maugier avatar Sep 25 '24 16:09 maugier

You could try to add a #box() after the #pinit-xxx function call, like #pinit-xxx()#box().

OrangeX4 avatar Oct 16 '24 08:10 OrangeX4