是否可以将 resizebox 合并到 R 中的 stargazer 中?我正在尝试创建一个太宽而无法容纳的 table ,即使是从横向角度来看也是如此。我手动将 resizebox{\textwidth}{!} {\begin{tabular}\end{tabular} } 添加到 .tex 文件中,我喜欢它的外观。但是,我希望我的 .Rnw 文件是完整的,这样我就可以完美地生成 pdf,而无需对 .tex 文件进行额外的更改。
在相关说明中,当没有指定标签时,stargazer 会导致 pdflatex 输出多个警告,因为它包含\label{}。这些不会影响 pdf 的创建,但是当存在其他错误时会引起混淆。
同样,我可以从 .tex 文件中手动删除这些行,或指定标签名称。但是,我想简单地告诉 stargazer 根本不要包含这条线。
最佳答案
这并不理想,但您可以使用 capture.output()
手动操作 stargazer 输出的 LaTeX 代码。和 gsub()
.
table <- capture.output({ # Store the stargazer output in a string
stargazer(iris, header=F) # e.g.
})
table <- gsub("\\begin{tabular}","\\resizebox{0.9\\textwidth}{!}{\\begin{tabular}", table,fixed=T)
table <- gsub("\\end{tabular}","\\end{tabular}}", table,fixed=T)
cat(table)
如果您在多个地方需要该过程,也可以将该过程提取到一个方法中。
关于r - 观星者选项 : resizebox and label,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28662394/