set_flextable_defaults: Modify flextable defaults formatting properties

View source: R/defaults.R

set_flextable_defaultsR Documentation

Modify flextable defaults formatting properties

Description

The current formatting properties (see get_flextable_defaults()) are automatically applied to every flextable you produce. Use set_flextable_defaults() to override them. Use init_flextable_defaults() to re-init all values with the package defaults.

Usage

set_flextable_defaults(
  font.family = NULL,
  font.size = NULL,
  font.color = NULL,
  text.align = NULL,
  padding = NULL,
  padding.bottom = NULL,
  padding.top = NULL,
  padding.left = NULL,
  padding.right = NULL,
  border.color = NULL,
  border.width = NULL,
  background.color = NULL,
  line_spacing = NULL,
  table.layout = NULL,
  cs.family = NULL,
  eastasia.family = NULL,
  hansi.family = NULL,
  decimal.mark = NULL,
  big.mark = NULL,
  digits = NULL,
  pct_digits = NULL,
  na_str = NULL,
  nan_str = NULL,
  fmt_date = NULL,
  fmt_datetime = NULL,
  extra_css = NULL,
  scroll = NULL,
  table_align = "center",
  split = NULL,
  keep_with_next = NULL,
  tabcolsep = NULL,
  arraystretch = NULL,
  float = NULL,
  fonts_ignore = NULL,
  theme_fun = NULL,
  post_process_all = NULL,
  post_process_pdf = NULL,
  post_process_docx = NULL,
  post_process_html = NULL,
  post_process_pptx = NULL,
  ...
)

init_flextable_defaults()

Arguments

font.family

single character value. When format is Word, it specifies the font to be used to format characters in the Unicode range (U+0000-U+007F). If you want to use non ascii characters in Word, you should also set hansi.family to the same family name.

font.size

font size (in point) - 0 or positive integer value.

font.color

font color - a single character value specifying a valid color (e.g. "#000000" or "black").

text.align

text alignment - a single character value, expected value is one of 'left', 'right', 'center', 'justify'.

padding

padding (shortcut for top, bottom, left and right padding)

padding.bottom, padding.top, padding.left, padding.right

paragraph paddings - 0 or positive integer value.

border.color

border color - single character value (e.g. "#000000" or "black").

border.width

border width in points.

background.color

cell background color - a single character value specifying a valid color (e.g. "#000000" or "black").

line_spacing

space between lines of text, 1 is single line spacing, 2 is double line spacing.

table.layout

'autofit' or 'fixed' algorithm. Default to 'autofit'.

cs.family

optional and only for Word. Font to be used to format characters in a complex script Unicode range. For example, Arabic text might be displayed using the "Arial Unicode MS" font.

eastasia.family

optional and only for Word. Font to be used to format characters in an East Asian Unicode range. For example, Japanese text might be displayed using the "MS Mincho" font.

hansi.family

optional and only for Word. Font to be used to format characters in a Unicode range which does not fall into one of the other categories.

decimal.mark, big.mark, na_str, nan_str

formatC arguments used by colformat_num(), colformat_double(), and colformat_int().

digits

formatC argument used by colformat_double().

pct_digits

number of digits for percentages.

fmt_date, fmt_datetime

formats for date and datetime columns as documented in strptime(). Default to '%Y-%m-%d' and '%Y-%m-%d %H:%M:%S'.

extra_css

css instructions to be integrated with the table.

scroll

NULL or a list if you want to add a scroll-box. See scroll element of argument opts_html in function set_table_properties().

table_align

default flextable alignment, supported values are 'left', 'center' and 'right'.

split

Word option 'Allow row to break across pages' can be activated when TRUE.

keep_with_next

default initialization value used by the paginate() function corresponding to the Word option "keep rows together" that will be defined in the array.

tabcolsep

space between the text and the left/right border of its containing cell.

arraystretch

height of each row relative to its default height, the default value is 1.5.

float

type of floating placement in the PDF document, one of:

  • 'none' (the default value), table is placed after the preceding paragraph.

  • 'float', table can float to a place in the text where it fits best

  • 'wrap-r', wrap text around the table positioned to the right side of the text

  • 'wrap-l', wrap text around the table positioned to the left side of the text

  • 'wrap-i', wrap text around the table positioned inside edge-near the binding

  • 'wrap-o', wrap text around the table positioned outside edge-far from the binding

fonts_ignore

if TRUE, pdf-engine pdflatex can be used instead of xelatex or lualatex. If pdflatex is used, fonts will be ignored because they are not supported by pdflatex, whereas with the xelatex and lualatex engines they are.

theme_fun

a single character value (the name of the theme function to be applied) or a theme function (input is a flextable, output is a flextable).

post_process_all

Post-processing function that will allow you to customize the the table. It will be executed before call to post_process_pdf(), post_process_docx(), post_process_html(), post_process_pptx().

post_process_pdf, post_process_docx, post_process_html, post_process_pptx

Post-processing functions that will allow you to customize the display by output type (pdf, html, docx, pptx). They are executed just before printing the table.

...

unused or deprecated arguments

Value

a list containing previous default values.

See Also

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

Examples

ft_1 <- qflextable(head(airquality))
ft_1

old <- set_flextable_defaults(
  font.color = "#AA8855",
  border.color = "#8855AA"
)
ft_2 <- qflextable(head(airquality))
ft_2

do.call(set_flextable_defaults, old)

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