How to align underbraces

As you can see below, the A, B, and C are at different heights. Could them be aligned?

$
  underbrace(1/10, A) times
  underbrace(1 / (k_B T), B) times
  underbrace(F / (1/2 u v), C).
$

My failed attempts

If you still want to see, click to expand.

I make a vphantom that draws an invisible vertical line of the height of body, but that doesn’t quite work.

#let vphantom(body) = box(width: 0pt, hide(body))

$
  underbrace(1 / (10 vphantom(1/2)), A) times
  underbrace(1 / (k_B T vphantom(1/2)), B) times
  underbrace(F / (1/2 u v vphantom(1/2)), C).
$

Adding v(1.2em) makes them vertically aligned, but denominators are now left shifted.

$
  underbrace(1 / (10 #v(1.2em)), A) times
  underbrace(1 / (k_B T #v(1.2em)), B) times
  underbrace(F / (1/2 u v #v(1.2em)), C).
$

1 Like

This is adapted from here: https://www.reddit.com/r/typst/comments/1cvhfh9/vhphantom_of_latex_equivalent/

#let vphantom(body) = hide({ body; context h(-measure(body).width) })

#let vp = vphantom[$1/2$]
$
  underbrace(1 / (vp 10), A) times
  underbrace(1 / (vp k_B T), B) times
  underbrace(F / (vp 1/2 u v), C).
$

It’s good that this is so easy to implement, but seems like function that would be ‘nice to have’ – I use this a lot in LaTeX.

Edit: Tweaking a bit to simplify.

3 Likes

BTW, I think it looks better, and is more ‘correct’ to render the labels as text:

$
  underbrace(1 / (vp 10), "A") times
  underbrace(1 / (vp k_B T), "B") times
  underbrace(F / (vp 1/2 u v), "C").
$

Otherwise, are the Bs in the label and the expression the same? What does it mean?

Cool, thank you!

They’re just placeholder contents. In my actual formula, the k_B is k_"B", and the B in the under brace is "noise". I’ve removed all "…" to make the example simpler.