Skip to main content
fontsize() changes the font size (in points) of a selection of cells in a flextable.

Function signature

fontsize(x, i = NULL, j = NULL, size = 11, part = "body")

Parameters

x
flextable
required
A flextable object.
i
integer | formula | logical
Row selector. Accepts integer indices, a one-sided formula (e.g., ~ col > 5), or a logical vector. NULL selects all rows in the specified part.
j
integer | character | formula
Column selector. Accepts integer indices, column names, a formula, or a logical vector. NULL selects all columns.
size
integer
default:"11"
Font size in points.
part
string
default:"body"
Which part of the table to target: "body", "header", "footer", or "all".

Return value

The modified flextable object.

Examples

Set font size for the header and individual columns:
ft <- flextable(head(iris))
ft <- fontsize(ft, size = 14, part = "header")
ft <- fontsize(ft, size = 14, j = 2)
ft <- fontsize(ft, size = 7, j = 3)
ft

See also

  • font() — set font family
  • bold()
  • color()
  • style() — apply multiple formatting properties at once
  • set_flextable_defaults(font.size = ...) — set the default font size for all new tables