Reputation: 479
How to make newlines in inline chunks ? Rendering a word document
---
title: "R Notebook"
output: word_document
---
Cat `r cat("not \n working")`
writeLines `r writeLines("not \n working")`
print `r print("not \n working")`
capture.output + cat `r capture.output(cat("not \n working"))`
```{r results='asis'}
cat("not \n working")
```
EDIT Solution based on shafee and gaut's answers uses triple escape character \
---
title: "R Notebook"
output: word_document
---
Text `r "Simple \\\n is \\\n better"`
Upvotes: 3
Views: 256
Reputation: 19917
You can use combine_words
from {knitr}
to do this in inline code.
`r knitr::combine_words(c("it is", "working"), sep = "\\\n", and = "")`
Upvotes: 3
Reputation: 5958
We can use:
```{r results='asis'}
cat(paste("it is", "\\\n", "working"))
```
Upvotes: 2