Line breaks in R Markdown text (not code blocks)
You can also use native LaTeX instructions if you use Knit to generate the PDF output. This would break the other output formats such as HTML though... :
e.g. :
In Markdown part
---
output: pdf_document
---
# test 1
No spaces used
line1\linebreak
line2
line3\linebreak line4
\linebreak and \newline seem to both work...
As R expressionr paste0("test","\\linebreak ", "test2")
Output is :
test
test2
Don't forget to add a trailing space after "\linebreak "...
This also allows to center paragraphs.
See also : Centering image and text in R Markdown for a PDF report
It's a rather old question, but I post an answer since it's the first hit when googling for "line breaks in rmarkdown".
If compiling to pdf, you can use latex macros. Substitute the **
in the new line with \hfill\break
:
# Introduction
The Tufte-\LaTeX\ [^tufte_latex] document**
\hfill\break
classes define a style similar to the style Edward Tufte uses in his books...
The best way I have found to add blank lines is:
# First title
<br><br><br><br><br>
# Second title with 5 blank spaces above it
You can try this, hopefully it helps. I have tested in html_documents only, but presumably it would work in pdf as well.
I tried these tests, it seems to be working:
test.Rmd
---
output: pdf_document
---
# test 1
No spaces used
line1
line2
# test 2
2spaces at the end of line1
line1
line2
# test 3
2spaces at the end of line1, then 2 spaces on next line
line1
line2
sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] htmltools_0.2.6 tools_3.2.0 yaml_2.1.13 rmarkdown_0.5.1 digest_0.6.8