Skip to contents

Returns a new table-format function that behaves like `table_format` but with the supplied font sizes injected. This is the generic mechanism used by [generate_slides()] to honor per-slide `font_size` settings declared in the spec: a single `table_format` symbol can carry body/header/footer sizes.

Sizes are only forwarded to arguments the underlying formatter actually declares. A formatter with an explicit `body_font_size`/`header_font_size`/ `footer_font_size` argument (or a `...`) receives the corresponding size; sizes a formatter cannot accept are dropped rather than raising an "unused argument" error. When no sizes are supplied the original formatter is returned unchanged.

Usage

with_font_sizes(
  table_format,
  body_font_size = NULL,
  header_font_size = NULL,
  footer_font_size = NULL
)

Arguments

table_format

A function taking a flextable as its first argument and returning a flextable (e.g. [autoslider_format()], [black_format_tb()]).

Point sizes. `NULL` (the default) leaves that part to the underlying formatter default.

Value

A function `function(ft, ...)` returning a styled flextable.

Examples

small <- with_font_sizes(black_format_tb, body_font_size = 6, header_font_size = 6)
ft <- flextable::flextable(head(mtcars))
small(ft)

mpg

cyl

disp

hp

drat

wt

qsec

vs

am

gear

carb

21.0

6

160

110

3.90

2.620

16.46

0

1

4

4

21.0

6

160

110

3.90

2.875

17.02

0

1

4

4

22.8

4

108

93

3.85

2.320

18.61

1

1

4

1

21.4

6

258

110

3.08

3.215

19.44

1

0

3

1

18.7

8

360

175

3.15

3.440

17.02

0

0

3

2

18.1

6

225

105

2.76

3.460

20.22

1

0

3

1