如何在R中使用Hmisc将注释添加到latex表格中?

5

一种不太优雅的方法是直接添加带有注释文本的tex代码行。

但在R中使用Hmisc包中的latex函数是否有更本地化的制作注释的方法?


1
这不是 insert.bottom 参数应该做的吗? - joemienko
1
@joemienko 这非常接近,但 insert.bottom.width 仅适用于 longtable,因此注释将比表格更宽。 - Anton Tarasenko
1个回答

0

有一种方法不是使用Hmisc,而是使用starpolishr包。

install.packages("devtools")
library(devtools)
install_github("ChandlerLutz/starpolishr");library(starpolishr)

使用caption宏包插入脚注

la<-latex(mtcars[1:2,1:5],file="example.tex",caption = "table using caption",
    where="!htbp") 
file0<-readLines("example.tex") 
file0<-star_notes_tex(file0, note = "file using caption*") 
cat(file0, file = paste0(getwd(),"/file0.tex"),sep="\n")

使用threeparttable插入脚注

注意,在Hmisc :: latex中必须使用caption和label参数。

mt <- mtcars[1:2,1:5]
mt[1,1]<-paste0(mt[1,1],"\\tnote{*}")
la<-latex(mt,file="example1.tex",label=" ",caption="table using threeparttable",
    where="!htbp") 
file1<-readLines("example1.tex") 
file1<-star_notes_tex(file1, note.type = "threeparttable",
note = "* notes with threeparttable : For this example you must use both label and caption, the
 threepartable code is meant to be used with tables generated by
 stargazer where a row with label is present. Otherwise the threepart table 
 argument is badly positionned.")
cat(file1, file = paste0(getwd(),"/file1.tex"),sep="\n")

footnotes


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接