Why are line breaks suppressed in content blocks inside aligned equations?

Hi. I want to add some comments to a multi-line calculation:

$
  &1 + 1 \

  =&2 \
  & #[
      Hello \
  
      World
    ]
$

I expected that the contents inside #[] would be treated as a block. However, line-breaks inside #[] are suppressed, and if I manually force a line-break with \, it breaks the alignment.

Why? Thank you.

Hi. When you write a code block, you should use the appropriate language identifier to get correct syntax highlighting.


You can use place() to insert a block that will not interfere with anything:

#lorem(10)
$
    & 1 + 1   \
  = & 2       \
    & #place[
        Hello

        World
      ]
$
#lorem(10)

image

But if there is text below, then it will overlap it, so instead you can try using block:

#lorem(10)
$
    & 1 + 1   \
  = & 2       \
    & #align(start, block[
        Hello \
        World
      ])
$
#lorem(10)

image

For easier use:

#lorem(10)
#let in-math(body) = align(start, block(body))
$
    & 1 + 1   \
  = & 2       \
    & #in-math[
        Hello \
        World
      ]
$
#lorem(10)

You are just entering code mode and then markup mode, since you can add this inline, it is like box, but not actually a box, nor it’s a block. It will add inner content directly, so how it will be laid out is up to the compiler.

1 Like

Hey @AprilGrimoire, welcome to the forum! I’ve changed your question post’s title to better fit our guidelines: How to post in the Questions category

Make sure your title is a question you’d ask to a friend about Typst. (Note how the title is much clearer now!) :wink:

Also, make sure to mark Andrew’s answer as a solution with the :white_check_mark: button if it has solved your problem. Otherwise, let us know what you still need help with.

1 Like