How do I create same star sign like LaTex?

I try to move my master thesis from latex to typst and I need a star sign.

\raisebox{0.4mm}{$\bigstar$}

It is looking like that in LaTex:
image

I try do same thing in Typst like that:
#strong[#underline[ UNIVERSITY \u{2605} GRADUATE]]
image

It is looking small and underline is not looking same.

Maybe it’s an issue with your chosen font. I’m not able to reproduce the problem.

This code:

#strong[#underline[ UNIVERSITY \u{2605}#sym.star.filled GRADUATE]]

Produces this result:
image

Thanks for answer. Still, the star is smaller than LaTeX. By the way, I use Times New Roman font.

Changing the size of the star and adjusting the baseline can be achieved by adjusting baseline and text.size.

#set text(font: "Times New Roman")

// Attempt to adjust the underline
// #set underline(stroke: 0.5pt, offset: 2pt)

#strong(
  underline(
    [UNIVERSITY
      #box(baseline: -0.025em, text(size: 1.3em)[
        ★])
      GRADUATE],
  ),
)

// Simulate Underline
#strong(
  box(stroke: (bottom: 0.5pt,), outset: 1pt,
    [UNIVERSITY
      #box(baseline: -0.025em, text(size: 1.3em)[★])
      GRADUATE],
  ),
)

However, it does not play nicely with the underline. Try the commented line above.

Some pointers I have found: Can't use `over-/underline()` with any space symbol or `h()` · Issue #1716 · typst/typst · GitHub

2 Likes

Check the documentation for underline: by default the stroke and offset depend on the current text settings, so if you use a larger font size for the star, it will affect the underline of that character. As @vmartel08 suggests you can set the stroke and offset values in the underline call to use the same values for the whole piece of text. I would do it like this:

#let star = text(2em, baseline: 0.08em, sym.star)
#strong[#underline(stroke: 0.04em, offset: 0.08em)[UNIVERSITY #star GRADUATE]]

image

By using em values everywhere we ensure the result will adapt nicely when you change the text size.

The star itself doesn’t look the same because in LaTeX \bigstar is taken from the AMS symbol font instead of the surrounding text font. If you want exactly the same star maybe you can get it from a TrueType/OpenType version of the AMS symbol font like this one.

5 Likes

Thanks everyone;

#let star = text(14pt, font: "Times New Roman", sym.star)
#strong[#underline(stroke: 0.04em, offset: 0.08em)[UNIVERSITY #star GRADUATE]]

This is fix the problem.

2 Likes