How to indent section of text

How can I indent an entire section of text?

For example

The following is indented:
#h(20pt) First line \
#h(20pt) Second line

#h(20pt) $ "equations should also work" $

Normal indentation again

but without having to insert the #h(20pt) every time.

Is that possible in an easy way?

1 Like

Have a look at Paragraph Function – Typst Documentation, indentation.

The following is indented:

#set par(first-line-indent: 20pt, hanging-indent: 20pt)

First line #lorem(100)

Second line

$"inline equations should also work"$
$ "block equations are handled separately" $

#set par(first-line-indent: 0pt, hanging-indent: 0pt)

Normal indentation again

For this it only works on the first line

  #set par(first-line-indent: 20pt, hanging-indent: 20pt)

  Minimierung von $tilde(f)^l_alpha_l$ mit
  $
    tilde(f)^l_alpha_l (x) = f(x) + alpha_l/2 (uv(x)^l - x)^T (ov(x)_l - x)
  $ 
  mit $x^l = [uv(x)^l, ov(x)^l]$ und $alpha_l >= max {0, -min_(x in X^l) lambda_min (x)}$

  #set par(first-line-indent: 0pt, hanging-indent: 0pt)

It does work when I add a / after the equation, but then the next line is pushed to the next page (it’s right at the end of the page), without the / it fits beneath the eqaution.

This is a mix of problems:

  1. first-line-indent is ignored for the “first” paragraph after certain elements (headings and block equations)
  2. If you add a \ after the equation, this will make the following paragraph start with a blank line (and the line with text on it then follows hanging-indent.
    This means that if there isn’t a pagebreak there, it will add additional vertical whitespace.
  3. Block equations are not affected by either indent, but also unaffected by placing a #h(20pt) infront of them (this h will be on its own line and not affect the equation)
Code for example image
#[
  #set par(first-line-indent: 20pt, hanging-indent: 20pt)

  The first paragraph always has a `first-line-indent` of 0.
  #lorem(10)
  
  Later paragraphs respect `first-line-indent`. #lorem(10)
  
  Minimierung von $tilde(f)^l_alpha_l$ mit
  $
    tilde(f)^l_alpha_l (x) = f(x) + alpha_l/2 (bold(x)^l - x)^T (bold(x)_l - x)
  $
  mit $x^l = [bold(x)^l, bold(x)^l]$ und $alpha_l >= max {0, -min_(x in X^l) lambda_min (x)}$.
  This is handled as a "first paragraph" because it follows a block equation.
]

Normal indent. #lorem(20)

#lorem(20)
$
  tilde(f)^l_alpha_l (x) = f(x) + alpha_l/2 (bold(x)^l - x)^T (bold(x)_l - x)
$
#lorem(20)


As an alternative solution, you might want to use Padding Function – Typst Documentation instead. This will also move the block equation to the right:

#pad(left: 20pt)[  
  Minimierung von $tilde(f)^l_alpha_l$ mit
  $
    tilde(f)^l_alpha_l (x) = f(x) + alpha_l/2 (bold(x)^l - x)^T (bold(x)_l - x)
  $
  mit $x^l = [bold(x)^l, bold(x)^l]$ und $alpha_l >= max {0, -min_(x in X^l) lambda_min (x)}$.
]

Normal indent. #lorem(20)
$
  tilde(f)^l_alpha_l (x) = f(x) + alpha_l/2 (bold(x)^l - x)^T (bold(x)_l - x)
$

(If you don’t want the very first line to be indented, you can add a #h(-20pt):

#pad(left: 20pt)[
  #h(-20pt)
  Minimierung ...

)

Have a look at How to have first line indent in a new paragraph after a math block? - #2 by miles-1

@Amasica, a trivial method is #block(inset: (left:

#block(
	inset: (left: 1em),
	[
		Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
	]
)