How to omit indent of paragraph after math block?

Heya, I’m having indented paragraphs

  #set par(
    first-line-indent: (amount: 30pt, all: true),
    justify: true,
  )

because I want to have indent after headings too. But this does include indent after math blocks too:

#lorem(30)
$
1+1 = 2
$
#lorem(30)

where I don’t want to indent the following normal text paragraph, as it should be just continuation of the first one. Is there a built-in noob-friendly way how to achieve both at the same time? Thank you!

Edit: Now irrelevant since the question was updated.

Hello @Vaclav_Bocan , this seems similar to How can I change the spacing between lines of a math.equation in "block" mode? - #4 by SillyFreak

I would try something like

#show math.equation.where(block: true): set par(first-line-indent: 0pt)

Although from your example, it doesn’t matter as the block equations are centered by default.

I guess the problem is Unexpected indentation after figures, lists and block equations (#3206).

图片

The workaround is adding a line break and wrapping with a box of width: 100%.

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

= Bad

#lorem(10), for example,
#box[$ integral x + y = z $] 
shows that the integral of $x + y$ is $z$.

= Good

#lorem(10), for example, \  // 👈 Add a line break
#box(width: 100%)[$ integral x + y = z $]  // 👈 Wrap with a box
shows that the integral of $x + y$ is $z$.

The solution can simpler if your equations are numbered. Refer to How to avoid indentation after equations and figures — FAQ | Typst Chinese Community for details.
(It’s in Chinese, but I guess reading the codes is enough. I can translate it if you need.)

Sorry, I didn’t explain well. I meant indent in the second lorem paragraph, not indent of the math block. I edited the question for better clarity.

Thanks, this works! But it changes the height of the equation, see image below (eq. 3 is with your box, eq. 4 is what I had before with wrong indentation)

I think that’s designed: it changes from par.spacing to par.leading. (See the example image in Paragraph Function – Typst Documentation for their difference.)

If you want to adjust it, you can use box(inset: (y: 0.5em), width: 100%, …) instead.

1 Like