问题描述
我正在尝试使用flextable
构建APA样式的表,该表将导出为.docx格式。我需要页脚的第一个单词为斜体字,但不需要后面的(脚注等)。我还没做到。
下面是一个小例子:
require(flextable)
tab <- data.frame("Variable" = c("Reference norm","Suject","Cutoff"),"Indicators"= c("Content 1","Content 2","Content 3"),"Reference norm" = c("","Content 4","Content 5"),"Subject" = c("","","Content 6"))
tab <- flextable(tab)
tab <- add_footer_lines(tab,values = "Note.") # This is where I need italic font
tab <- footnote(tab,i= 2,j= 2:3,part = "body",ref_symbols="a",value = as_paragraph("Method x"),inline=T)
解决方法
require(flextable)
tab <- data.frame(
"Variable" = c("Reference Norm","Suject","Cutoff"),"Indicators" = c("Content 1","Content 2","Content 3"),"Reference Norm" = c("","Content 4","Content 5"),"Subject" = c("","","Content 6")
)
tab <- flextable(tab)
# start with an empty line
tab <- add_footer_lines(tab,values = "")
# add "Note: "
tab <- compose(tab,i = 1,j = 1,value = as_paragraph(as_i("Note: ")),part = "footer")
# add some footnotes
tab <- footnote(tab,i = 2,j = 2:3,part = "body",ref_symbols = "a",sep = "",value = as_paragraph("Method x"),inline = T)
# add other footnotes
tab <- footnote(tab,i = 3,ref_symbols = "b",sep = "; ",value = as_paragraph("Method y"),inline = T)
tab <- fontsize(tab,part = "all",size = 13)
autofit(tab)