1

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

それを修正する方法はありますか?

4

0 に答える 0