1

Although the problem described in How to set both column width and text alignment in align argument of xtable? looks the same and solution looks promising I can't get this working.

---
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}|")))
```

The newcolumntype declaration seems to be wrong in my example, but I don't know how to fix it. The error I'm getting is:

! Undefined control sequence.
<recently read> \newcolumntype

Any ideas how to fix it?

Community
  • 1
  • 1
  • Possible duplicate of [How to set both column width and text alignment in align argument of xtable?](http://stackoverflow.com/questions/33208777/how-to-set-both-column-width-and-text-alignment-in-align-argument-of-xtable) – CL. Oct 20 '15 at 17:55

0 Answers0