R和Latex使用xtable进行基线对齐

问题描述 投票:0回答:1

我正在使用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

r latex knitr
1个回答
0
投票

xtable包不支持添加该可选参数,但是您可以通过编辑结果自己添加它。例如,

© www.soinside.com 2019 - 2024. All rights reserved.