我正在使用knitr / sweave动态生成R代码并将其包含到我的乳胶文档中。我的最小代码是:
list <- c("Bike", "Train", "Bike", "Bike", "Bike", "Train", "Bike", "Bike", "Bike", "Moped", "Bus", "Moped", "Train", "Bus", "Moped", "Bike","Moped")
library(xtable)
print(xtable(table(list)),floating=FALSE,booktabs=TRUE)
这产生作为输出:
\begin{tabular}{rr}
\toprule
& list \\
\midrule
Bike & 8 \\
Bus & 2 \\
Moped & 4 \\
Train & 3 \\
\bottomrule
\end{tabular}
我想要的是使tabular
环境与基线(即\begin{tabular}[t]{rr}...\end{tabular}
)对齐。
xtable
文档中有table.placement
,但这引入了table
环境。我尝试了tabular.environment
并将其设置为tabular[t]
,但由于它给了\begin{tabular[t]}
而无法正常工作>
如何解决此问题?
我正在使用knitr / sweave动态生成R代码并将其包含到我的乳胶文档中。我的最小代码是:list
xtable
包不支持添加该可选参数,但是您可以通过编辑结果自己添加它。例如,