6

I am trying to use knitr::kable in Rmarkdown to create a table of latex equations. However, I am having difficulties getting special characters such as $\sum$ or $\hat$ to work. For example the following works:

knitr::kable(head(mtcars[,c(1,2)], 10),
         row.names = FALSE,
         col.names = c("Time", "$\\delta_{m}_1$"))

but when trying to include a hat or bar the following does not work:

knitr::kable(head(mtcars[,c(1,2)], 10),
         row.names = FALSE,
         col.names = c("Time", "$\\hat{m}_1$"))

Has anyone figured out how to embed these characters using kable?

Thanks

Grant Adams
  • 61
  • 1
  • 2
  • Welcome on SO! Could you please add some info about `output_format` (`html_document`, `pdf_document` or other) and `knitr` chunk options? It would be more useful to post a minimal `Rmd` file. Thanks! – RLesur Feb 19 '18 at 21:00
  • The second one renders as expected when I try. – user20650 Feb 19 '18 at 21:06
  • @user20650 me too. I got the first one with `"$\\delta{m}_1$"`. – RLesur Feb 19 '18 at 21:12
  • Thanks all, it works when I knit it, but not when I run the code chunk in the console just with `{r echo = F} `. My mistake... – Grant Adams Feb 19 '18 at 21:52

0 Answers0