How can I have parenthesis ignore underbrace vertical spacing?

Note: Possibly related to How can I underbrace only part of a matrix? - #2 by xkevio

How can I underbrace a term in parenthesis without having the parenthesis increase in height? Here is an equation:

Screenshot 2025-01-06 at 1.09.33 PM

When I add underbrace inside the parens, the parens vertically expand to fit the underbraces

Screenshot 2025-01-06 at 1.10.31 PM

I would like to label the terms with the underbraces outside the parenthesis, such that the parenthesis do not become taller.

You can escape the delimiters resulting in

$
  "Pr"(cal(X) = x) = \{ omega in underbrace(Omega, "Outcomes") | underbrace(cal(X)(omega), "Map outcome to real") = x \}
$

image

although preferably you would use a package like pinit

#import "@preview/pinit:0.2.2": *

$
  "Pr"(cal(X) = x) = 
  { 
    omega in #pin(1)Omega#pin(2)
    | 
    #pin(3)cal(X)(omega)#pin(4) = x
  }
$

#pinit-highlight(1, 2)
#pinit-point-from((1,2), pin-dx: 0pt, offset-dx: 5pt)[Outcomes]

#pinit-highlight(3, 4, fill: blue.transparentize(80%))
#pinit-point-from((3,4),)[Map outcome to real]

image

Another possibility is to use lr to set the size of the braces and midline explicitly:

$
  "Pr"(cal(X) = x) = lr(size: #1em, { omega in underbrace(Omega, "Outcomes") |
    underbrace(cal(X)(omega), "Map outcome to real") = x })
$

This way you can manually tune the height. I guess you could even measure the height of the formula without underbrace and use that for size.

2 Likes