How to avoid a linebreak when using the skew function?

Hi!

I am trying to “emulate” italic text using skew, but when I use the simple show rule as visible in the MWE, the result is not exactly what I expected.

Some context: the reason I’m trying to do this, is that for certain documents I am required to use provided font files which do not contain italic definitions unfortunately. Without any special rules in Typst, any text wrapped in _ is rendered as if it was regular text. In LaTeX, FakeSlant is used to mitigate this problem. For Typst, a show rule using skew seemed appropriate to me but I have difficulties getting it to work.

My MWE:

= Without show rule

Some content and some _emphasized_ content.

= With show rule

#show emph: skew.with(ax: -30deg, reflow: false)

Some content and some _emphasized_ content.

The rendered result:

As can be seen in the image, the part using the emph show rule appears to behave like a block, which I don’t want. I’d like it to be in-line, just as normal emph text would be.

I’ve tried both reflow: false and reflow: true.

It’s probably an easy fix but I don’t have any more ideas currently so help is welcome!

You can try wrapping it in Box Function – Typst Documentation. This allows you to integrate block-level elements in a paragraph.

1 Like

Right on the money! Thank you very much.

My show rule now looks like this:

#show emph: it => {
  box(skew(it, ax: -17deg))
}

I don’t think it can be made more concise?

#show emph: it => box(skew(ax: -17deg, it))

#show emph: skew.with(ax: -17deg)
#show emph: box