使用ReporteRs
包时,似乎将文本放入页面页脚的唯一方法是在文本正文中放置一个带编号的脚注,并使该脚注显示为相同的数字页脚。我希望能够将文本放在页面的页脚中而不需要任何编号。
library(ReporteRs)
doc1 <- docx()
doc1 <- addFlexTable(doc1,vanilla.table(head(iris)))
Foot <- Footnote()
Foot <- addParagraph(Foot,"This should not have a number in front of it")
doc <- addParagraph(doc,pot("There should be no number after this",footnote=Foot))
writeDoc(doc1, file = "footnote1.docx")
或者,如果可以在页面底部放置一个段落,那也可以解决我的问题。这可以通过确定页面上可以容纳多少行来完成,但是如果有某种方法可以将垂直对齐方式作为最后一段的页面底部,那将是理想的。
doc2 <- docx()
doc2 <- addFlexTable(doc2,vanilla.table(head(iris)))
doc2 <- addParagraph(doc2,c(rep("",33),"Text placed by dynamically finding bottom of the page"))
writeDoc(doc2, file = "footnote2.docx")
答案 0 :(得分:1)
您尝试执行的操作与编写的ReporteRs::Footnote
不符,如帮助中所示:
如果在docx对象中,脚注将被紧跟在注释引用的文本部分之后的数字标记。
但是,如果我正确理解你的问题,你所追求的是可以实现的。表格中的注释和页脚中的文本不会以任何方式连接,例如Footnote
提供的超链接。
还有一个问题是ReporteRs
没有提供在不使用书签的情况下在页脚中放置文字的方法(Footnote
除外,我们现在已经打折)。这意味着我们需要使用 docx 模板而不是包生成的空文档。
步骤:
FOOTER
,然后点击添加 ReporteRs
使用我们的新模板,接下来的步骤似乎更为熟悉。
library(ReporteRs)
doc <- docx(template = "Doc1.docx")
# do the flextable, note that I add your table footer here
ftable <- vanilla.table(head(iris))
ftable <- addFooterRow(
ftable,
value = c("There should be no number after this"),
colspan = 5
)
doc <- addFlexTable(doc, ftable)
# check for the presence of our bookmark
list_bookmarks(doc)
# [1] "FOOTER"
# now add the footer text using the bookmark
doc <- addParagraph(
doc, stylename = "footer", bookmark = "FOOTER",
pot("This should not have a number in front of it")
)
# and finally write the document
writeDoc(doc, file = "doc.docx")
该表格,您可以更好地格式化以适应,我没有删除添加的行上的边框。
标准页脚样式的页脚,您可以再次修改以适应。