Skip to contents

The 'Keep with next' functionality in 'Word', applied to the rows of a table, ensures that the rows with that attribute stays together and does not break across multiple pages.

This function allows much better control of breaks between pages than the global keep_with_next parameter.

Usage

keep_with_next(x, i = NULL, value = TRUE, part = "body")

Arguments

x

a flextable object

i

rows selection

value

TRUE or FALSE. When applied to a group, all rows except the last one should be flagged with attribute 'Keep with next'.

part

partname of the table (one of 'all', 'body', 'header', 'footer')

See also

paginate()

Other sugar functions for table style: align(), bg(), bold(), color(), empty_blanks(), font(), fontsize(), highlight(), italic(), line_spacing(), padding(), rotate(), tab_settings(), valign()

Examples

library(flextable)
dat <- iris[c(1:25, 51:75, 101:125), ]
ft <- qflextable(dat)
ft <- keep_with_next(
  x = ft,
  i = c(1:24, 26:49, 51:74),
  value = TRUE
)

save_as_docx(ft, path = tempfile(fileext = ".docx"))