R Markdown Cheat Sheet
Your one-stop reference for R Markdown syntaxβcovering inline code, code chunks, formatting rules, and more. Explore concise examples and see rendered outputs to help you combine R code and narrative seamlessly.
Quick Reference
Jump to any R Markdown syntax to get started quickly
Inline Elements
(12 items)Block Elements
(9 items)R Markdown Syntax
Essential R Markdown elements for creating dynamic documents that combine narrative text, code, and results. These features enable reproducible research and interactive reports.
Inline Elements
Plain Text
inlineBasic text content without any special formatting.
R Markdown Input
Plain text.
Rendered Output
Plain text.
π‘ Tips
- No special syntax needed for regular text.
- Forms the foundation of all Markdown documents.
Line Breaks
inlineCreate line breaks using two spaces at the end of a line or a backslash.
R Markdown Input
End a line with two spaces to
start a new paragraph.
Also end a line with a backslash\
to make a new line.
Rendered Output
End a line with two spaces to
start a new paragraph.
Also end a line with a backslash
to make a new line.
π‘ Tips
- Two spaces at line end create a line break within the same paragraph.
- Backslash at line end also creates a line break.
- Empty line creates a new paragraph.
Text Emphasis
inlineApply italic and bold formatting to text using asterisks.
R Markdown Input
*italics* and **bold**
Rendered Output
italics and bold
π‘ Tips
- Single asterisks for italics: *text*
- Double asterisks for bold: **text**
- Can be combined: ***bold and italic***
Superscript and Subscript
inlineCreate superscript and subscript text using caret and tilde symbols.
R Markdown Input
superscript^2^/subscript~2~
Rendered Output
superscript2/subscript2
π‘ Tips
- Use ^text^ for superscript.
- Use ~text~ for subscript.
- Useful for mathematical expressions and chemical formulas.
Strikethrough
inlineCross out text using double tildes.
R Markdown Input
~~strike through~~
Rendered Output
strike through
π‘ Tips
- Use double tildes: ~~text~~
- Useful for showing deleted or outdated content.
Escaped Characters
inlineDisplay special Markdown characters literally using backslashes.
R Markdown Input
escaped: \* \_ \\
Rendered Output
escaped: * _ \
π‘ Tips
- Use backslash before special characters to display them literally.
- Common escaped characters: \*, \_, \\, \#, \+
Dashes
inlineCreate en-dash and em-dash using double and triple hyphens.
R Markdown Input
en dash: --, em dash: ---
Rendered Output
en dash: β, em dash: β
π‘ Tips
- Double hyphen -- creates en-dash (β)
- Triple hyphen --- creates em-dash (β)
- En-dash for ranges, em-dash for breaks in thought.
Automatic Links
inlineCreate clickable links by wrapping URLs in angle brackets.
R Markdown Input
<https://tomarkdown.dev>
Rendered Output
π‘ Tips
- URLs automatically become clickable when wrapped in < >.
- Works with http, https, and email addresses.
- For custom link text, use the bracket syntax instead.
Link with Custom Text
inlineCreate links with custom display text using bracket and parenthesis syntax.
R Markdown Input
[This is a link.](https://tomarkdown.dev)
Rendered Output
π‘ Tips
- Format: [display text](URL)
- Display text can be different from the actual URL.
- Can include title attribute: [text](URL "title")
Reference-Style Links
inlineCreate links using reference IDs defined elsewhere in the document.
R Markdown Input
[This is another link.][id].
At the end of the document:
[id]: https://tomarkdown.dev
Rendered Output
π‘ Tips
- Keeps text cleaner by separating link text from URLs.
- Define references anywhere in document.
- Useful for documents with many repeated links.
Inline Code
inlineDisplay code inline using single backticks.
R Markdown Input
`verbatim code`
Rendered Output
verbatim code
π‘ Tips
- Use single backticks for short code snippets.
- Text inside backticks is displayed literally.
- Useful for variable names, function names, etc.
Inline Math
inlineInsert mathematical expressions inline using single dollar signs.
R Markdown Input
equation: $e^{i \pi} + 1 = 0$
Rendered Output
π‘ Tips
- Use single $ for inline math: $equation$
- LaTeX syntax supported for mathematical notation.
- Requires MathJax or similar math renderer.
Block Elements
Headers
blockCreate headers of different levels using hash symbols.
R Markdown Input
# Header 1
## Header 2
...
###### Header 6
Rendered Output
Header 1
Header 2
...Header 6
π‘ Tips
- Number of # symbols determines header level.
- Space required after # symbols.
- Headers automatically create anchor links in HTML output.
Unordered Lists
blockCreate bullet point lists using hyphens, with support for nesting.
R Markdown Input
- unordered list
- item 2
- item 2a (indent 1 tab)
- item 2b
Rendered Output
- unordered list
- item 2
- item 2a (indent 1 tab)
- item 2b
π‘ Tips
- Use - (hyphen) for list items.
- Indent with tab or 4 spaces for nesting.
- Can also use + or * instead of -.
Ordered Lists
blockCreate numbered lists, with support for mixing with unordered lists.
R Markdown Input
1. ordered list
2. item 2
- item 2a (indent 1 tab)
- item 2b
Rendered Output
- ordered list
- item 2
- item 2a (indent 1 tab)
- item 2b
π‘ Tips
- Use numbers followed by period: 1., 2., etc.
- Can mix ordered and unordered lists through nesting.
- Actual numbers don't matter - Markdown auto-numbers.
Images
blockInsert images using exclamation mark followed by link syntax.
R Markdown Input

or

At the end of the document include:
[id2]: https://github.githubassets.com/assets/GitHub-Logo-ee398b662d42.png
Rendered Output
π‘ Tips
- Format: 
- Alt text important for accessibility.
- Can use reference style like links.
- Supports relative and absolute paths.
Code Blocks
blockDisplay multiple lines of code using triple backticks.
R Markdown Input
```
multiple lines
of verbatim code
```
Rendered Output
multiple lines
of verbatim code
π‘ Tips
- Use triple backticks for multi-line code.
- Can specify language for syntax highlighting: ```r
- All text inside is displayed literally.
Block Quotes
blockCreate indented quote blocks using greater-than symbol.
R Markdown Input
> block quotes
Rendered Output
block quotes
π‘ Tips
- Use > at beginning of line for quotes.
- Can be nested with multiple > symbols.
- Often styled with different background or border.
Math Blocks
blockCreate standalone mathematical equations using double dollar signs.
R Markdown Input
equation block:
$$E = mc^{2}$$
Rendered Output
equation block:
π‘ Tips
- Use double $$ for block math equations.
- Equations are centered and displayed prominently.
- Supports complex LaTeX mathematical expressions.
Horizontal Rule
blockCreate horizontal dividing lines using three hyphens.
R Markdown Input
horizontal rule:
---
Rendered Output
horizontal rule:
π‘ Tips
- Use three or more hyphens on their own line.
- Creates visual separation between sections.
- Can also use *** or ___
Tables
blockCreate formatted tables using pipes and hyphens for alignment.
R Markdown Input
|Right|Left|Default|Center|
|----:|:---|-------|:----:|
|12 |12 |12 |12 |
|123 |123 |123 |123 |
|1 |1 |1 |1 |
Table: Caption text, example rendered table
Rendered Output
Right | Left | Default | Center |
---|---|---|---|
12 | 12 | 12 | 12 |
123 | 123 | 123 | 123 |
1 | 1 | 1 | 1 |
π‘ Tips
- Use | to separate columns.
- Alignment: :-- (left), --: (right), :--: (center), --- (default)
- Add Table: caption below table for table caption.
- Header row separated by alignment row.
Explore More Cheatsheets
Discover other Markdown guides for different platforms and use cases
Markdown Cheatsheet
Complete guide to standard Markdown syntax with examples and live previews