3

I am trying to insert a line break inside the header paragraph in rmarkdown.

---
title: "Untitled"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
someValue <- 1
```

## `r paste0("1. Attempt to set line break here ->  \n new line with value: ", someValue)`

## `r paste0("2. Attempt Line Feed, U+000A here ->  ",intToUtf8(strtoi("0x000A"))," new line with value: ", someValue)`

## `r paste0("3. Attempt Vertical Tab, U+000B here ->  ",intToUtf8(strtoi("0x000B"))," new line with value: ", someValue)`

## `r paste0("4. Attempt Form Feed, U+000C here ->  ",intToUtf8(strtoi("0x000C"))," new line with value: ", someValue)`

## `r paste0("5.  Carriage Return, U+000D here ->  ",intToUtf8(strtoi("0x000D"))," new line with value: ", someValue)`

## `r paste0("6. Next Line, U+0085 here ->  ",intToUtf8(strtoi("0x0085"))," new line with value: ", someValue)`

## `r paste0("7. Line Separator, U+2028 here ->  ",intToUtf8(strtoi("0x2028"))," new line with value: ", someValue)`

## `r paste0("8.  Paragraph Separator, U+2029 here ->  ",intToUtf8(strtoi("0x2029"))," new line with value: ", someValue)`

## `r paste0("9.  Breaks ->  <br> new line with value: ", someValue)`

## `r paste0("|\n  |10. Pipes break here ->   \n  | new line with value: ", someValue)`

## `r paste0("|\n  <center>11. Center tag here ->   </center>\n  <center>new line with value: ", someValue, "</center>")`

## Unsuitable <br>  
## as giving two separate paragraps and wrong TOC

This code is returning wrong output.

enter image description here

Unfortunately I failed to get any useful information from here as well.

So I am stuck. Please, can anyone help me to set the line break from inside the R code?

Appended

upon @MrFlick comment.

Here is the desired output - a multiline (single) paragraph with user defined positions of line breaks (equivalent of Word's SHIFT + ENTER).

enter image description here

asd-tm
  • 3,381
  • 2
  • 24
  • 41
  • So you're saying all these attempts do not do what you want? What exactly is the desired output? – MrFlick Sep 08 '22 at 12:54
  • @MrFlick Thank you for your attention to my question. I've appended it. – asd-tm Sep 08 '22 at 13:26
  • Would it be possible to use an HTML/PDF file as output to solve this issue? Sometimes you can use export the word doc with specific references, [link here](https://bookdown.org/yihui/rmarkdown-cookbook/word-template.html) – Daniel_j_iii Sep 10 '22 at 14:14
  • @Daniel_j_iii Thank you for your comment. Unfortunately the file that is built by this code subects to future inevitable manual edit. That is why the Word document is expected. Concerning the link I did not catch your idea. the link denotes to styling not the structure of the document doesn't it? – asd-tm Sep 10 '22 at 21:44

0 Answers0