Environment to align text similar to formulas?

In formulas I might want to insert text descriptions:

$
  a = & f(b) \
  & #align(left, box[
      (text descriptions)
    ])
$

Sometimes the text descriptions can get very long and need multiple lines.
Instead of

(hello
world)

I think

(hello
 world)

looks better. I know this can be implemented with hide, but is there a way to do it like in formulas with &?

1 Like

This isn’t a very nice way to do it since it will quickly become tedious to enter a lot of text, but this can be used to get the result you want. Depending on what you use this for, there could be some ways to make it a bit easier to use (custom function that takes your data and formats it into a table).

(hello\
world)

#grid(
  columns: 3,
  rows: 1em, //Change this to match rest of the text
  [(], [hello], none,
  none, [world], [)]
)

While writing this up I had another idea, though I’m not sure it’s better. The opening parenthesis ( can be shifted to the left which then makes “hello” and “world” line up.

(hello\
world)

#let shift-left(body) = context {
  let body-width = measure(body).width
  place(
    dx: -body-width,
    body
  )
}

#shift-left([(])hello\
world)

2 Likes