观星者选项:resizebox和标签 [英] Stargazer options: resizebox and label

查看:755
本文介绍了观星者选项:resizebox和标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将resizebox合并到R的stargazer中?我正在尝试创建一个表格,该表格太大,即使从横向角度来看也无法容纳.我手动将resizebox {\ textwidth} {!} {\ begin {tabular} \ end {tabular}}添加到.tex文件,我喜欢它的外观.但是,我希望我的.Rnw文件完整,以便我可以完美地生成pdf,而无需对.tex文件进行其他更改.

Is it possible to incorporate resizebox into stargazer in R? I'm trying to create a table that is too wide to fit, even on landscape perspective. I manually added resizebox{\textwidth}{!} { \begin{tabular} \end{tabular} } to the .tex file, and I like how it looks. However, I'd like for my .Rnw file to be complete, so that I can generate pdf perfectly without additional changes to the .tex file.

在相关说明中,由于未指定标签,因此stargazer会导致pdflatex输出包括\ label {}在内的多个警告.这些不会影响pdf的创建,但是当存在其他错误时,它们会引起混乱.

On a related note, stargazer causes pdflatex to output multiple warnings due to it including \label{} when no label is specified. These don't affect the pdf's creation, but they cause confusion when there are other errors present.

同样,我可以从.tex文件中手动删除这些行,或分配标签名称.但是,我只想告诉观星者根本不要包括这一行.

Again, I can manually delete these lines from the .tex file, or assign label names. However, I would like to simply tell stargazer not to include this line at all.

推荐答案

这并不理想,但是您可以使用capture.output()gsub()手动操纵从注视者输出的LaTeX代码.

It's not ideal, but you can manually manipulate the LaTeX code output from stargazer with capture.output() and 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)

如果您需要在多个地方使用该过程,也可以将该过程提取到一种方法中.

You can also extract that procedure into a method if you need it in more than one place.

这篇关于观星者选项:resizebox和标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆