尽管如何在 xtable 的 align 参数中设置列宽和文本对齐方式中描述的问题?看起来一样,解决方案看起来很有希望我无法让它工作。
---
output: pdf_document
header-includes:
- \usepackage{longtable}
- \newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
---
```{r, results='asis', echo=FALSE, warning=FALSE}
library(xtable)
options(xtable.comment = FALSE)
addtorow <- list()
addtorow$pos <- list()
addtorow$pos[[1]] <- c(0)
addtorow$command <- c(paste("\\hline \n",
"\\endhead \n",
"\\hline \n",
"{\\footnotesize See next page} \n",
"\\endfoot \n",
"\\endlastfoot \n",
sep=""))
irisShort <- head(iris)
print(xtable(irisShort,
digits=rep(0,6),
align=c(
"p{0.015\\textwidth}|",
"R{0.37\\textwidth}|",
"R{0.12\\textwidth}|",
"R{0.08\\textwidth}|",
"R{0.02\\textwidth}|",
"p{0.35\\textwidth}|")))
```
在我的示例中,newcolumntype 声明似乎是错误的,但我不知道如何修复它。我得到的错误是:
! Undefined control sequence.
<recently read> \newcolumntype
任何想法如何解决它?