I’m curious how to use underbrace for an expression that’s split across multiple lines, for example, like shown in this LaTeX thread: amsmath - Multiline \underbrace in math mode - TeX - LaTeX Stack Exchange

Is it possible to modify math.underbrace
in typst
to change the left and right endpoints of the underbrace individually in this way?
Hello @brunokm,
it is unfortunately not possible to modify the built-in underbrace
function in such a way (unless you modify Typst source code).
Fortunately, Typst also has great drawing primitives, and I suggest to take a look at cetz’s brace
. Although it is heavily linked to the cetz library, the logic for drawing the brace does not change.
I’m not a drawing expert, but that seems doable, although fastidious.
This is a POC with missing alignment, case for a dotted brace if there are more than two breaks, and no actual braces, but it should give you the idea.
#let split-underbrace(..args) = {
let eqs = args.pos()
return for arg in eqs {
let b = $arg$
block(context {
let l = measure(b)
b
place(line(start: (0em, 0em), length: l.width - l.width * 0.30), dy: .25em)
// place an actual loop for dots, or use stroke: "dotted"
place(line(start: (l.width * 0.8, 0em), length: .1em), dy: .25em)
})
}
}
#split-underbrace($a+b$, $c+d$, $e+f$)

For the alignment, you can take a look at equate
1 Like