theme_zebra: Apply zebra theme

View source: R/themes.R

theme_zebraR Documentation

Apply zebra theme

Description

Apply theme zebra to a flextable

Usage

theme_zebra(
  x,
  odd_header = "#CFCFCF",
  odd_body = "#EFEFEF",
  even_header = "transparent",
  even_body = "transparent"
)

Arguments

x

a flextable object

odd_header, odd_body, even_header, even_body

odd/even colors for table header and body

behavior

Theme functions are not like 'ggplot2' themes. They are applied to the existing table immediately. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called.

That is why theme functions should be applied after all elements of the table have been added (mainly additionnal header or footer rows).

If you want to automatically apply a theme function to each flextable, you can use the theme_fun argument of set_flextable_defaults(); be aware that this theme function is applied as the last instruction when calling flextable() - so if you add headers or footers to the array, they will not be formatted with the theme.

You can also use the post_process_html argument of set_flextable_defaults() (or post_process_pdf, post_process_docx, post_process_pptx) to specify a theme to be applied systematically before the flextable() is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement.

See Also

Other functions related to themes: get_flextable_defaults(), set_flextable_defaults(), theme_alafoli(), theme_apa(), theme_booktabs(), theme_box(), theme_tron(), theme_tron_legacy(), theme_vader(), theme_vanilla()

Examples

ft <- flextable(head(airquality))
ft <- theme_zebra(ft)
ft

flextable documentation built on Oct. 30, 2024, 9:15 a.m.