Basic Markdown

Markdown

Quatro files consist of code and markdown. We have discussed how to code in the previous chapters and will discuss markdown here. Markdown is a specific kind of markup language. What we mean by that is that the text in the document also indicates how it should be formatted in the result (For example if we surround a word by double asterikses (like so **bold**) it will bold in the resulting output. Below we will discuss the different types of markup that you can use.

Basic Formatting

Syntax Output
*italics* italics
**bold** bold
***bold italics*** bold italics
subscript~2~ subscript2
superscript^2^ superscript2
~~crossed out~~ crossed out
`code` code

Headings

Syntax Output
# Header 1

Header 1

## Header 2

Header 2

### Header 3

Header 3

#### Header 4

Header 4

##### Header 5
Header 5
###### Header 6
Header 6

Images

Syntax Output
![Caption](Logo.svg) Caption
![Caption](Logo.svg) “hovertext” Caption
![Caption](Logo.svg){fig-alt=“Alt text”} Alt text

It is also possible to include images in links.

Lists

Markdown Syntax Output
* item 1
* item 2
    + sub-item 1
    + sub-item 2
        - sub-sub-item 1
  • item 1

  • item 2

    • sub-item 1

    • sub-item 2

      • sub-sub-item 1
*   item 2

    Part of item (Extra spaces)
  • item 2

    Part of item (Extra spaces)

1. ordered list
2. item 2
    i) sub-item 1
    ii) sub-item 2
         A.  etc.
  1. ordered list

  2. item 2

    1. sub-item 1
    2. sub-item 1
    A.  etc.

Tables

There are multiple ways to make tables

The easiest way is to use a so called pipe-table like this:

 | foo|  bar  | Left align | Right Align | Center |
 |----|-------|:-----------|------------:|:------:|
 | 1  |    2  | 1  |    2  | 1|  
 | 3  |    4  |3  |    4  | 4 |
 
 : an optional caption

The result is:

an optional caption
foo bar Left align Right Align Center
1 2 1 2 1
3 4 3 4 4

The first and last pipe character at each row are optional, the ones separating the columns are not although they do not have to be aligned. The header cannot be omitted. The relative width is determined by the number of dashes.

An alternative way to specify the relative column widths is by including the attribute after the caption, like this:

: an optional caption {tbl-colwidths="[40,15,15,15,15]"} 

Sometimes it is easiest to directly make the tables from R code.

Source code

You can use delimited blocks with three backticks to use source code formatting. The syntax:

````

foo <- bar

````

Becomes:

foo <- bar

It is possible to add an R to indicate the R language is used and apply apropriate highlighting:

``` R
foo <- bar
```

Becomes:

foo <- bar

Math

You can use TeX like syntax to format equations. Inline formulas are delimeted by single $s and display math uses double $$s.

Syntax Output
$a2=b2+c^2$ \(a^2=b^2+c^2\)
$$a2=b2+c^2$$ \[a^2=b^2+c^2\]