2016-08-04 81 views
0

我使用R中的ReporteRs包創建Word文檔,並且我想將單個間隔的段落間距改爲1.5間隔。使用R中的ReporteR更改docx中的行間距

我想我可以輸入每一行作爲一個新的段落,並在每個「段落」的開始放置一個緩衝區,但我正在尋找一種更乾淨的方式。

我打算使用另一個包,如果它會工作。

回答

0

您可以在空白Word文檔中定義一個行距爲1.5的段落(名稱爲myparag),並將其重新用作模板(文件名:template.docx)。

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

謝謝!這適用於我的段落,但同樣的技巧無法改變該段落中包含的腳註中的間距。腳註風格似乎是由段落風格決定的,但我想要一個單獨的腳註,並在1.5間隔的段落中引用該腳註。你能幫我嗎? – forest

0
## 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")