forest forest - 2 months ago 12x
R Question

Change line spacing in docx using ReporteRs in R

I'm creating a word document using the ReporteRs package in R, and I want to change the spacing of a paragraph from single spaced to 1.5 spaced.

I guess I could enter each line as a new paragraph and put a buffer at the start of each of those "paragraphs" but I'm looking for a cleaner way.

I'm open to using another package if it would work.


You could define a paragraph with line space 1.5 (with name myparag) in an empty Word document and reuse it as a template (filename: template.docx).

doc <- docx() 
styles( doc ) # check value `myparag` is in the available paragraph styles
doc <- addParagraph(doc, "Blah blah blah", stylename = "myparag")