简体   繁体   中英

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")
## docx example 
doc = docx( )

# Footnote definition
par1 = pot("About this reference", textItalic(font.size = 8) )
par2 = pot("Omni ab coalitos pro malivolus obsecrans graviter 
           cum perquisitor perquisitor pericula saepeque inmunibus coalitos ut.", 
           textItalic(font.size = 8) )

Footnote = Footnote( )
Footnote = addParagraph( Footnote, set_of_paragraphs( par1, par2 ), 
  parProperties(padding.top = 15))

# add text in the doc with previously defined footnote
my_pot = pot("Blah blah blah." ) + 
  pot(" Here is a note.", footnote = Footnote)
doc = addParagraph(doc, my_pot )

writeDoc( doc, file = "footnote.docx" )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM