2
```{r}
library(knitr)
text <- c("apple", "orange")
for(i in text){
  cat(paste("I have an", i))
}
```

In Rmarkdown, is there a way to format text outputted by a code chunk using the cat command? I know that I can format the font outside of the code chunk (e.g. ##Header to make it bigger and bolded, etc). But what about the text "inside" a code chunk?

Adrian
  • 9,229
  • 24
  • 74
  • 132
  • Does [this question help at all](https://stackoverflow.com/questions/26819258/format-text-inside-r-code-chunk)? – Anonymous coward Apr 11 '18 at 16:08
  • @Anonymouscoward thanks, it helps, but I tried doing `cat("\centering")` but I'm getting `\c` is an unrecognized escape as an error message – Adrian Apr 12 '18 at 02:13
  • You want "\\centering" (double backslash), but this is only going to work for LaTeX output. If you want HTML output it's completely different. You need to say which output format. – user2554330 Apr 12 '18 at 11:59

0 Answers0