How do I create an inline heading without first-line-indent?

I want to create an inline heading, similar to the \paragraph*{} command in latex.

The proposed solution I found here

#show heading.where(level: 4): it => block(strong(it.body) + [ ])

works somewhat well. However, I use

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

to indent the first line of a paragraph. Using the above solution, the inline heading is also indented, which I do not want. Instead, I want by formatting to be this:

INLINE HEADING some text  for this a heading. And
some more text.

   A new paragraph under this heading. Observe that it 
is indented, in contrast the the heading!

How do I do this?

#show heading.where(level: 4): it => {
  h(-1.8em)
  box(strong(it.body))
}
1 Like

I like it, thank you!

However, this can fail after a list or an equation:

This is a list:
- arst
- arst

==== This is indented beyond the boundary of the page

$
 1 = 0
$

==== This is also indented too much

How do I fix this?

Unfortunately Typst’s paragraph handling isn’t very consistent so you can’t do this automatically. The easiest way I see would be to define a command that adds the appropriate spacing and call it before every incorrectly indented heading:

#let indent = h(1.8em)

This is a list:
- arst
- arst

#indent
==== This is indented correctly

$
 1 = 0
$

#indent
==== This is fixed as well

I see, that’s a pity. Let’s hope I won’t regret writing my thesis with it. Thanks a lot!

Hi, I needed the same and used the following snippet. It worked perfectly for me, maybe it helps.

#show heading.where(level: 4): it => block(spacing: 0.65em) + box(strong(it.body) + [ ])
Result

test