02. Basic formatting with Markdown
Hear are examples of simple formating in Markdown. Note that everything demonstrated here, except the Equations section (section 4), is part of the base Markdown functionality.
Headings
We can create a heading with #
, so for a level one heading we use:
# Heading level 1
## Heading level 2
### Heading level 3
and so on. If we have numbered sections turned on (as we do in on this page), these headings will be automatically numbered.
Level 2 heading example
Like so
Simple text formating
As demonstrated in the prior page, we can wrap text with *
to get bold and italic text, but we have other formatting options too:
- bold text =
**bold text**
- italic text =
*italic text*
- bold and italic text =
***bold and italic text***
- Underlined text =
<u>Underlined text</u>
Deleted text=~~Deleted text~~
code
=`code`
-
blockquote =
> blockquote
- ==highlight== =
==highlight==
- H~2~O =
H~2~O
- X^2^ =
X^2^
Note that there are other ways of dealing with super and subscripts, please see the Equations section (section 4) for that.
Paragraphs
To start a new paragraph you need to leave a blank line.
This is a second paragraph. I’d recommend putting each sentence on separate lines as I find it easier to read when looking at the source file, and it comes in handy if you use version control, but this isn’t strictly needed.
For a horizontal rule use triple dashes (---
) on it’s own line:
As a general recommendation, if your output isn’t looking how you expect, try using blank lines between elements. Markdown likes things to have room to breath!
Footnotes
For footnotes we can use [^1]
by the text, and then define the footnote on a separate line with [^1]:
Here's a sentence with a footnote.[^1]
[^1]: This is the footnote.
Which looks like this:
Here’s a sentence with a footnote.1
Lists
To start an unordered list we can use a -
.
Note that there should be a blank line before and after the list.
For the sublist we simply indent the -
- one item
- one item
- one item
- one more item
- one more item
- one more item
For an ordered list we can use a number followed by a period: 1.
.
Note that the actual number doesn’t really matter as when the document is compiled it’ll render the list correctly.
If you check the source file for this page you’ll see that I just used 1.
repeatedly, and yet it renders as you’d want it to.
- the first item
- the second item
- the third item
- one unordered item
- one unordered item
Links and images
To insert a link we wrap the text we want to appear in []
and follow with the address in ()
:
- Example link =
[Example link](https://en.wikipedia.org/wiki/Hyperlink)
We can include an image in the same way, but with an !
at the begining:
- =
![Example image](example_image.jpg)
Note that I wouldn’t recommend inserting images like this when working with R Markdown as there are alternatives that are easier to control. Please see this page for more details on this.
Equations
Inline LaTeX equations can be made by wrapping with $
:
- Here is some inline maths
\(f(k) = {n \choose k} p^{k} (1-p)^{n-k}\)
=$f(k) = {n \choose k} p^{k} (1-p)^{n-k}$
Or for a equation block we can use double $$
:
$$f(k) = {n \choose k} p^{k} (1-p)^{n-k}$$
which looks like this:
$$f(k) = {n \choose k} p^{k} (1-p)^{n-k}$$
Greek letters
For Greek letters, we can just write the name of the letter after a \
Note that this needs to be in LaTeX math, so either wrapped in single $
or double $$
\(\alpha\)
==$\alpha$
\(\beta\)
==$\beta$
- TNF$\alpha$ ==
TNF$\alpha$
\(\frac{1}{\delta^2} \times \gamma_3\)
==$\frac{1}{\delta^2} \times \gamma_3$
There are lots of examples of more complex LaTeX math online if you need it, this page for instance
-
This is the footnote. ↩︎