Skip to contents

Change the first-line or hanging indent of paragraphs in selected rows and columns of a flextable.

A first-line indent moves only the first line of the paragraph to the right. A hanging indent moves all lines but the first one to the right; the indented lines start at the paragraph left padding plus the hanging value, so hanging should not exceed the left padding (see padding()).

Usage

indentation(
  x,
  i = NULL,
  j = NULL,
  first_line = NULL,
  hanging = NULL,
  part = "body"
)

Arguments

x

a 'flextable' object, see flextable-package to learn how to create 'flextable' object.

i

row selector, see section Row selection with the i parameter in <Selectors in flextable>.

j

column selector, see section Column selection with the j parameter in <Selectors in flextable>.

first_line

first-line indent in pts (points). Use NA to unset.

hanging

hanging indent in pts (points). Use NA to unset. If both first_line and hanging are provided, hanging wins.

part

part selector, see section Part selection with the part parameter in <Selectors in flextable>. Value 'all' can be used.

Examples

ft_1 <- flextable(head(iris))
ft_1 <- mk_par(
  x = ft_1, i = 1, j = 1, part = "header",
  value = as_paragraph("A rather long header that will wrap on two lines")
)
ft_1 <- padding(ft_1, i = 1, j = 1, padding.left = 30, part = "header")
ft_1 <- indentation(ft_1, i = 1, j = 1, hanging = 20, part = "header")
ft_1 <- width(ft_1, j = 1, width = 1.2)
ft_1

A rather long header that will wrap on two lines

Sepal.Width

Petal.Length

Petal.Width

Species

5.1

3.5

1.4

0.2

setosa

4.9

3.0

1.4

0.2

setosa

4.7

3.2

1.3

0.2

setosa

4.6

3.1

1.5

0.2

setosa

5.0

3.6

1.4

0.2

setosa

5.4

3.9

1.7

0.4

setosa