Skip to contents

Split a flextable into a list of flextables whose body rows fit within a given height (in inches). Header and footer are repeated on every page. An optional group argument keeps row groups together (no page break inside a group).

Usage

split_rows(x, max_height, group = integer(0), unit = "in")

Arguments

x

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

max_height

Maximum height for each page, including header and footer (in inches by default).

group

Integer vector of body row indices that start a new group. Rows belonging to the same group are kept together on a single page. Default is integer(0) (no grouping, every row is independent).

unit

Unit for max_height, one of "in", "cm", "mm".

Value

A list of flextable objects. If no splitting is needed, a single-element list is returned.

Note

Footnotes are currently repeated on every page, even when they reference rows that only appear on a specific page. This limitation will be resolved in a future version when footnotes are restructured to track their association with body rows.

Examples

ft <- flextable(iris)
ft_pages <- split_rows(ft, max_height = 3)
length(ft_pages)
#> [1] 19