Change the padding of selected rows and columns of a flextable.
Usage
padding(
x,
i = NULL,
j = NULL,
padding = NULL,
padding.top = NULL,
padding.bottom = NULL,
padding.left = NULL,
padding.right = NULL,
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
iparameter in <Selectors in flextable>.- j
column selector, see section Column selection with the
jparameter in <Selectors in flextable>.- padding
padding (shortcut for top, bottom, left and right), unit is pts (points).
- padding.top
padding top, unit is pts (points).
- padding.bottom
padding bottom, unit is pts (points).
- padding.left
padding left, unit is pts (points).
- padding.right
padding right, unit is pts (points).
- part
part selector, see section Part selection with the
partparameter in <Selectors in flextable>. Value 'all' can be used.
Note
In PDF output, padding.top and padding.bottom are ignored by
default: for a long time they were not supported, and row heights
were only driven by arraystretch. To keep existing PDF tables
unchanged, applying them is opt-in with the padding_vertical
option (see set_flextable_defaults() or opts_pdf in
set_table_properties()), preferably with arraystretch = 1:
set_flextable_defaults(padding_vertical = TRUE, arraystretch = 1).
They are then supported with the "fixed" layout (the default) but
not with the "autofit" layout.
Global horizontal spacing can also be set with
set_table_properties(opts_pdf = list(tabcolsep = 1)).
See also
Other formatting shortcuts:
align(),
bg(),
bold(),
color(),
empty_blanks(),
font(),
fontsize(),
highlight(),
indentation(),
italic(),
keep_with_next(),
line_spacing(),
rotate(),
style(),
tab_settings(),
valign()
Examples
ft_1 <- flextable(head(iris))
ft_1 <- theme_vader(ft_1)
ft_1 <- padding(ft_1, padding.top = 4, part = "all")
ft_1 <- padding(ft_1, j = 1, padding.right = 40)
ft_1 <- padding(ft_1, i = 3, padding.top = 40)
ft_1 <- padding(ft_1, padding.top = 10, part = "header")
ft_1 <- padding(ft_1, padding.bottom = 10, part = "header")
ft_1 <- autofit(ft_1)
ft_1
Sepal.Length
Sepal.Width
Petal.Length
Petal.Width
Species
5.1
3.5
1.4
0.2
setosa
4.9
3.0
1.4
0.2
setosa
4.7
3.2
1.3
0.2
setosa
4.6
3.1
1.5
0.2
setosa
5.0
3.6
1.4
0.2
setosa
5.4
3.9
1.7
0.4
setosa
