2

I am working on many kables using the kableExtra package. Say you have a dataframe,df, that is 5 rows and 5 columns.

in R you can do names(df)=c("A","B","C","D","E") for example.

Once you have the names of the dataframe set like that you can simply plug in the dataframe into kable to make a table.

My question is, I want some of the names to include other symbols. For example I want one column name to be like

$\widehat{A}$

I.e an A with a widehat above it.

Is it possible to do this? if so, how?

Thanks

  • 1
    CTAN has no latex package called kableExtra , this appears to be more of an R question than tex? it might be better to ask in an R forum. (with no link to any latex package and no example document provided I couldn't even guess any answer, sorry) – David Carlisle Sep 30 '19 at 20:05
  • Thank you, I will check out the R forums – Quality Sep 30 '19 at 20:06
  • 1
    @DavidCarlisle kableExtra is a R package that can produce LaTeX tables, and thus imho this question is on-topic. – Fran Sep 30 '19 at 20:10
  • @Fran so I guessed but still it's only marginally on topic. If I was writing a C++ program that happened to be outputting latex and got stuck with the C++ syntax I'm not sure I should ask for C++ help here. Just because the R is generating latex doesn't mean that R help is on topic. Usually R users can post the generated tex and frame the question as a tex question to keep things clearly on topic. But anyway note I didn't say it was off topic (and didn't vote to close) I just asked if an R help site might be a better place to ask.. – David Carlisle Sep 30 '19 at 20:14
  • At least in Stack Exchange seems that there are not a clear place to ask about R specifically. There R tags in both stack overflow and cross validated but being this question related with LaTeX, seems even more marginal in these forums that in this site, that have also an r tag with now 474 questions. – Fran Sep 30 '19 at 21:50
3

It is possible, but to pass to LaTeX \widehat you should write in R \\widehat. MWE in Rmarkdown:

---
output:
  pdf_document: default
---

```{r test, echo=FALSE}
df <- data.frame(A=c(1,2,4),B=c(6,2,4))
names(df) <- c("$\\widehat{A}$","$\\widehat{B}$")
knitr::kable(df)
```

mwe

  • Perfect. thanks! – Quality Sep 30 '19 at 22:36
  • @Quality For future questions it would be helpful to provide some minimal compilable code with your question as Fran did in their answer. – Alan Munn Sep 30 '19 at 23:32
  • I will be sure to do that. – Quality Oct 1 '19 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.