rflextableline-spacing

Best way to double space table with flextable?


Using package flextable, and reading from the different help pages, I could not find how to double (line) space an entire table, as APA requires.

There's the option hrule():

ft_1 <- flextable(head(iris))
ft_1 <- height(ft_1, height = 1, part = "body")
ft_1 <- height(ft_1, height = 1, part = "head")
ft_1 <- hrule(ft_1, rule = "exact", part = "body")
ft_1 <- hrule(ft_1, rule = "exact", part = "head")
ft_1

Or padding():

ft_1 <- flextable(head(iris))
ft_1 <- padding(ft_1, padding = 20, part = "all")
ft_1

But in both cases, when I check in Word, it doesn't correspond to double (line) spacing (it is still single spacing there).

Question

Is there a better option to make sure it 100% corresponds to double line spacing ("Line and Paragraph Spacing" in Word)?

I assume that using hrule() or padding could create various formatting problems later on, or editors might complain it doesn't correspond to the right kind of double spacing (e.g., it doesn't respond to changing spacing manually after so its harder to change through conventional means).

Or are we expected to manually change to double spacing in Word manually after exporting? Thank you.


Solution

  • I have created a new function named line_spacing (flextable >= 0.5.11). It should do what you want:

    ft_1 <- qflextable(head(iris))
    ft_1 <- line_spacing(ft_1, space = 1.5, part = "all")
    ft_1
    

    enter image description here