How to have first line indent in a new paragraph after a math block?

Hello. I always use first line indents for my paragraphs. When I write equations in an article, sometimes I add a new paragraph immediately after a math block, like this:

    Lorem ipsum dolor sit amet 
             a^2+b^2=c
    New paragraph should be indented. Lorem ipsum dolor sit amet

Right now Typst seems to not support this, and doesn’t indent my new paragraph after the math block no matter what I do. Here’s what I’ve tried:

#set par(first-line-indent: 2em)
#lorem(30)
$ A xor B dot.circle C = D^2 mod F^2 $

#parbreak()
New paragraph (No indent)

Second paragraph (Indent appears)

If I were writing in markdown, I would’ve just put a tab before the newline and most software would acknowledge it. Does anyone know how to do this? I am very new to Typst.

You’re right, Typst currently only indents successive paragraphs, and doesn’t indent the first paragraph after block content. To work around this, you can use the h function (horizontal space function):

#set par(first-line-indent: 2em)
#lorem(30)
$ A xor B dot.circle C = D^2 mod F^2 $

#h(2em) New paragraph (now with indent)

Second paragraph (Indent appears)

If you only use one block equation at a time and a paragraph always follows a block equation, you can use a show rule to make this change for all paragraphs:

#set par(first-line-indent: 2em)

#show math.equation: it => {
  it
  if it.block {
    h(2em)
  }
}

#lorem(30)
$ A xor B dot.circle C = D^2 mod F^2 $

New paragraph (now with indent, even without `h` in front)

Second paragraph (Indent appears)
1 Like

If the equation block is in the middle position of paragraph, the solution also add the indentation to the next line. Is there any method to avoid this?

First note that Typst now has a setting for indenting the first line of all paragraphs using first-line-indent: (amount: xxx, all: true):

#set par(first-line-indent: (amount: 2em, all: true))

#lorem(30)
$ A xor B dot.circle C = D^2 mod F^2 $

#lorem(30)

Now the problem is that in many cases, a block equation should not start a new paragraph. This has been discussed in this thread:

1 Like