vignettes/test/markdown.Rmd
markdown.Rmd
This is an illustration of the basic (R) Markdown formattings, as they are rendered in a {pkgdown} site using the {svPkgdown} style.
Take care that a blank line is required before headers as #22 this could too easily be interpretted as a header otherwise.
[linking to a header]
, or
[linking to a header][]
should work too: this is a link to
the [abstract][].{-}
or
{.unnumbered}
(providing, of course, that the other headers
are numbered).Bold using bold or bold
Italic using italic or italic, but intra_word_underscore is not interpreted (use stars for that like in this word)
Superscript, or subscript. No space can occur inside super- or subscript. If you need it, backslash-escape the space like Pa cat.
Strikethrough with this formatting.
Formattings can be combined of course, like bold italic with superscript.
Inline code like x <- 1
, and if you need
backquote inside it `@var` <- 2
.
Links are automatically detected like http://example.com, or can be explicitly indicated (with a different text) like some example. Note that Markdown uses also reference links. You can also put your links between angle brackets http://example.com.
You can use any UTF-8 character (at least for HTML documents (examples: µm, Ω, Æ, ∫√)…
You need to backslash-escape punctuation you don’t want to be interpreted ad formatting code, like *foo*.
A non-breaking space is simply an escaped space, like between “Fig.” and “3” here: Fig. 3.
A few sequences of characters produce special characters. Use of –dashes– and —em-dashes—. Three dots is ellipsis… and I can use any unicode, too, for special characters, like 😌.
Some quoted text
With two paragraph…
More quoted
with a second paragraph within the same quote block.
And double quotation
with two paragraphs…
Preformatted text:
Some preformatted text using indentation
Preformatted or verbatim sections indented with four spaces of
fenced (but only fenced blocks work in lists and are thus the preferred
mean to do so). Fenced blocks are delimited by three or more tildes
(~
) or backticks (`
) and they must be
separated from the surrounding using blank lines. You can use
identifiers too like in this block:
Some preformatted text (like for code blocks)
using a fenced block with backticks
It is very easy to indicate a language, and syntax highlighting will be used for it:
# Idem, but with R syntax highlighting
for (i in 1:100) {
if (i > 1) stop("Got it!")
}
It can also be specified in a more complex way, and with marks allowing to link to it:
Then you can link to it like here.
*
,
-
or _
optionally separated by spacesLine breaks when ending with two or more spaces
like this paragraph. However, this is not very visible, nor usable in
table. So you can also use a backslash followed by a newline
and this approach is the only way to do it in tables!
You can escape special characters except in code block or inline code if you don’t want them to be interpreted as formatting marks like _here_.
Non-breaking space is entered as a backslash-escaped space
(\
).
Comment that do not appear in the final document are similar to
HTML comments (<!-- comment-->
), but can also be
entered using the [//]:
syntax.
Smart punctuation is used and converts straight quotes into curly
ones like ‘here’ or “here”. It will also interpret --
as
en-dash –, ---
as em-dash —, and ...
as
ellipses … Moreover, non- breaking spaces are automatically used after
certain items like Mr. Schmidt.
Note that raw HTML (with or without interpretation of markdown inside it) can be included too.
Footnotes1 are easy to insert. Another example2. And here, I use an inline footnote3.
Text after the long note…
Unordered list (using *
, +
or
-
)
Compact
list
of items
Loose
list
of items
Ordered list
Back to first level
There is a mechanism to include paragraphs inside the list using indentation (don’t forget the empty line in between to start a new paragraph):
Some preformatted inside a list item
Fourth item
#.
for ordered
lists, as well as something like 1)
, or (I)
for instance::
or ~
) and blank lines are optional between
the term and its definition (loose vs compact form), but not
before the term. Finally, several definitions are allowed for the same
term.Definition 1
Definition 2
{ some code, part of Definition 2 }
Third paragraph of definition 2.
or
@.
syntax:Some text
You can give them labels (alphanumeric + character + hyphen) and refer to them later on. You can also enclose it into parentheses, but it does not change how it is displayed:
And what if I refer to it before the label like 5? Yes! It works! But unfortunately, there is no link to example 5.
Finally, to force ending a list, just add a comment where you want to end it (same trick applies for restarting another numbered list):
list item
another item
Formatted block with spaces does not work inside lists
third list item
Formatted block with spaces work now
Indent paragraphs or blocks or chunks (see hereunder) following a list item to include it in the list:
The area of a circle with a given radius is:
radius <- 3.5
pi * radius ^ 2
## [1] 38.48451
As you can see, the R chunk and its associated results are included in the list element!
Image from the Internet:
Inline equations like , or .
Display equation
Here is a more complex example spanning on several lines:
With {pkgdown} and standard Pandoc, it is not easy to get numbered display equations and cross-references to these equations. Here is an example:
… and you can reference Eq. $\ref{my-equation}$ like this.
If you feel difficult to write LaTeX equations, there are inline LateX equation editors like this one, and you don’t need to install anything on your computer to used them. Also, there is an RStudio addin provided with the {bookdown} R package to ease writing LaTeX equations in your R Markdown document.
You have both the font awesome, and the themify icons. You need to create an object of class “fa fa-xxxx”, or “ti-xxxx”, where “xxxx” is an icon in the collection. Here is an example from font awesome , and here is one from themify: . You can use these icons everywhere!
This is my simple footnote.↩︎
Footnotes can span on multiple paragraphs, providing you indent them with four spaces:
Another paragraph belonging to the note.↩︎
Inline footnotes are easier to write right in your text, but they can only span on a single paragraph.↩︎
Note that you cannot include the number inside the link, unfortunately.↩︎