Learn R Programming

flextable (version 0.9.11)

keep_with_next: Set Word 'Keep with next' instructions

Description

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

This function provides better control of page breaks than the global keep_with_next parameter.

Usage

keep_with_next(x, i = NULL, value = TRUE, 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>.

value

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

part

part selector, see section Part selection with the part parameter in <Selectors in flextable>. Value 'all' is not allowed by the function.

See Also

paginate()

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

Examples

Run this code
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"))

Run the code above in your browser using DataLab