0

I am working on a project in R-markdown. I have been trying to get the 'n' to italicize but I keep getting error messages. Listed below is my latest attempt.

```{r, echo=FALSE, message=FALSE, warning=FALSE, results="asis"} 
print(xtable(describe(PDS_Admin[3:15]), align="lccccccccccccc", 
             caption=paste("Descriptive Statistics for PDS Administrators", italic(n), "= 13")), 
             type="latex", caption.placement= "top", comment=F, latex.environments ="flushleft") 
```

I know this seems like a mundane detail. Please help!

Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
asokol
  • 119
  • 1
  • 16

1 Answers1

1

You can use LaTeX tags, such as \textit{} for italics, directly inside the caption:

```{r, results="asis"}
## Note the \\ that escapes the '\' character
xtable(mtcars[1:13,], align="lccccccccccc", type="latex",
  caption="Built-in mtcars dataset for \\textit{n} = 13")
```

enter image description here

Artem Sokolov
  • 13,196
  • 4
  • 43
  • 74