How can the appearance of overline or macron be specified in detail?

In math, the overline(U) is frequently used to denote closure, but the Typst-defined function ‘overline’ doesn’t have a good appearance for some fonts. Is there a way to specify the height, position, length, and thickness of that ‘bar’? One of my attempts is the following:

#show math.equation: set text(font: "STIX Two Math", size: 12pt)
#let overU = $ limits(U)^(#line(start: (1pt,0pt),end: (8pt,0pt), stroke: 0.7pt) #h(0.6pt) \ #v(-6.3pt) ) $ 

However, it seems to have some problems when adding a subscript, like:

$ overU_(i) $

Is there a way to fix this?

Just to be clear as to the question title and as you said, Typst does have overline() and macron() in math mode. Font issues usually stem from non-proper math fonts, though sometimes they can be the fault of Typst.

It would be good to know what fonts you had issues with or what those were specifically. There might have also been some bug fixes regarding accent placement that will arrive in 0.12. One alternative seems to be: $accent(U, \u{0305})$ which is called dash on main.

Thank you for the reply. I used the font ‘STIX Two Math’ with a size of 12pt (as indicated in the first line of the code). I also tried this option, but it seemed too short from my perspective. I would like to have more control over the ‘bar,’ especially since I also need to handle complex conjugates sometimes.

Hmm, I see. I have modified your attempt to make it a little less cluttered:

#show math.overline: it => $limits(it.body)^#box(baseline: 2pt, line(length: 1em, stroke: 0.7pt))$

There, you can play around with baseline to move it closer to the body, though I don’t see what’s wrong with the subscript.

Would you be able to show us what your overline supscript looks like? On my side I cannot see any issues. See below
image

Code
#show math.equation: set text(font: "STIX Two Math", size: 12pt)
#let overU = $ limits(U)^(#line(start: (1pt,0pt),end: (8pt,0pt), stroke: 0.7pt) #h(0.6pt) \ #v(-6.3pt) ) $
#set page(width: auto, height: auto)

$
  "overline(\"very long text\")"& : overline("very long text")\
  "overline(x)"&: overline(x)\
  "overU"&:overU\
  "macron(x)"&: macron(x)\
$

Thanks for your reply, I think @xkevio provides an almost perfect solution.

My complaint is the overline(U) or macron(U) is either too long or too short, and my previous attempt added a small spacing before the subscript:

@xkevio 's solution solves this problem. However, it introduces a new problem when I use the entity as a subscript.
where zb is defined as @xkevio suggested

#let zb = $limits(z)^(#h(0.7pt)#box(height: -2.1pt, line(length: 0.55em, stroke: 0.7pt)))$

For the moment, I will go with @xkevio’s solution, and simply define a new overline where I try to use it in the subscript.

I’m glad you found @xkevio‘s post helpful!

Can you mark it as the solution using the :ballot_box_with_check: button to help other users with the same problem?

Perhaps, writing

#let zb = $limits(z)^(#h(0.7pt)#box(height: -0.15em, line(length: 0.55em, stroke: 0.7pt)))$

would work better for you. I changed the height to -0.15em.
image

1 Like