diff --git a/resource/markdown.qmd b/resource/markdown.qmd index e8735d5..5b1342b 100644 --- a/resource/markdown.qmd +++ b/resource/markdown.qmd @@ -4,164 +4,111 @@ title: Using Markdown [Markdown](https://daringfireball.net/projects/markdown/) is a special kind of markup language that lets you format text with simple syntax. You can then use a converter program like [pandoc](https://pandoc.org/) to convert Markdown into whatever format you want: HTML, PDF, Word, PowerPoint, etc. ([see the full list of output types here](https://pandoc.org/MANUAL.html#option--to)) -## Basic Markdown formatting - - ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Type……or……to get
Some text in a paragraph.
-More text in the next paragraph. Always -use empty lines between paragraphs.

Some text in a paragraph.

-

More text in the next paragraph. Always -use empty lines between paragraphs.

\*Italic\*\_Italic\_Italic
\*\*Bold\*\*\_\_Bold\_\_Bold
# Heading 1

-Heading 1 -

## Heading 2

-Heading 2 -

### Heading 3

-Heading 3 -

(Go up to heading level 6 with ######)
\[Link text\](http://www.example.com)Link text
!\[Image caption\](/path/to/image.png)Class logo
`` `Inline code` `` with backticksInline code with backticks
> Blockquote
-

Blockquote

-
- Things in
-- an unordered
-- list
* Things in
-* an unordered
-* list
    -
  • Things in
  • -
  • an unordered
  • -
  • list
  • -
1. Things in
-1. an ordered
-2. list
1) Things in
-1) an ordered
-2) list
    -
  1. Things in
  2. -
  3. an ordered
  4. -
  5. list
  6. -
Horizontal line
-
----
Horizontal line
-
-***

Horizontal line

-
++------------------------------------------+-----------------------------------------------------------------------------+ +| Type... | ...to get | ++==========================================+=============================================================================+ +| ``` default | Some text in a paragraph. | +| Some text in a paragraph. | | +| | More text in the next paragraph. Always use empty lines between paragraphs. | +| More text in the next paragraph. Always | | +| use empty lines between paragraphs. | | +| ``` | | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `*Italic*` or `_Italic_` | *Italic* | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `**Bold**` or `__Bold__` | **Bold** | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `# Heading 1` | # Heading 1 | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `## Heading 2` | ## Heading 2 | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `### Heading 3` | ### Heading 3 | ++------------------------------------------+-----------------------------------------------------------------------------+ +| (Go up to heading level 6 with `######`) | | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `[Link text](https://www.example.com)` | [Link text](https://www.example.com) | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `![Image caption](path/to/image.png)` | ![Image caption](/files/course-icon.png){width=30%} | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `` `Inline code` `` with backticks | `Inline code` with backticks | ++------------------------------------------+-----------------------------------------------------------------------------+ +| Block of code with triple backticks: | | ++------------------------------------------+-----------------------------------------------------------------------------+ +| ```` default | ``` default | +| ``` | Block of code in between | +| Block of code in between | triple backticks | +| triple backticks | ``` | +| ``` | | +| ```` | | ++------------------------------------------+-----------------------------------------------------------------------------+ +| Optionally specify a language: | | ++------------------------------------------+-----------------------------------------------------------------------------+ +| ```` default | ``` r | +| ``` r | x <- c(1, 3, 5, 7) | +| x <- c(1, 3, 5, 7) | plot(x) | +| plot(x) | ``` | +| ``` | | +| ```` | | ++------------------------------------------+-----------------------------------------------------------------------------+ +| `> Blockquote` | > Blockquote | ++------------------------------------------+-----------------------------------------------------------------------------+ +| ``` default | - Things in | +| - Things in | - an unordered | +| - an unordered | - list | +| - list | | +| ``` | | ++------------------------------------------+-----------------------------------------------------------------------------+ +| ``` default | 1. Things in | +| 1. Things in | 2. an ordered | +| 1. an ordered | 3. list | +| 2. list | 4. Notice that the | +| 3. Notice that the | 5. numbers don't | +| 8. numbers don't | 6. matter | +| 18. matter | | +| ``` | | ++------------------------------------------+-----------------------------------------------------------------------------+ +| ``` default | Horizontal line | +| Horizontal line | | +| | --- | +| --- | | +| ``` | | ++------------------------------------------+-----------------------------------------------------------------------------+ + +: {tbl-colwidths="[50,50]"} + ## Math Markdown uses LaTeX to create fancy mathematical equations. There are like a billion little options and features available for math equations—you can find [helpful examples of the the most common basic commands here](http://www.malinc.se/math/latex/basiccodeen.php). -You can use math in two different ways: inline or in a display block. To use math inline, wrap it in single dollar signs, like ``\$y = mx + b\$``: - - ---- - - - - - - - - - - - - -
Type……to get
Based on the DAG, the regression model for
-estimating the effect of education on wages
-is $\hat{y} = \beta_0 + \beta_1 x_1 + \epsilon$, or
-$\text{Wages} = \beta_0 + \beta_1 \text{Education} + \epsilon$.
Based on the DAG, the regression model for +You can use math in two different ways: inline or in a display block. To use math inline, wrap it in single dollar signs, like `$y = mx + b$`: + +::: {.callout-tip} +### Inline math + +**Type…** + +```default +Based on the DAG, the regression model for estimating the effect of education on wages is $\hat{y} = \beta_0 + \beta_1 x_1 + \epsilon$, or -$\text{Wages} = \beta_0 + \beta_1 \text{Education} + \epsilon$.
+$\text{Wages} = \beta_0 + \beta_1 \text{Education} + \epsilon$. +``` + +**…to get…** + +> Based on the DAG, the regression model for estimating the effect of education on wages is $\hat{y} = \beta_0 + \beta_1 x_1 + \epsilon$, or $\text{Wages} = \beta_0 + \beta_1 \text{Education} + \epsilon$ + +::: To put an equation on its own line in a display block, wrap it in double dollar signs, like this: +::: {.callout-tip} +### Block math + **Type…** -```text +```default The quadratic equation was an important part of high school math: $$ @@ -181,6 +128,8 @@ But now we just use computers to solve for $x$. > > But now we just use computers to solve for $x$. +::: + --- Because dollar signs are used to indicate math equations, you can't just use dollar signs like normal if you're writing about actual dollars. For instance, if you write `This book costs $5.75 and this other costs $40`, Markdown will treat everything that comes between the dollar signs as math, like so: "This book costs \\(5.75 and this other costs \\)40". @@ -192,9 +141,12 @@ To get around that, put a backslash (`\`) in front of the dollar signs, so that There are 4 different ways to hand-create tables in Markdown—I say "hand-create" because it's normally way easier to use R to generate these things with packages like [{gt}](https://gt.rstudio.com/) or [{knitr}](https://bookdown.org/yihui/rmarkdown-cookbook/kable.html) or [{kableExtra}](https://haozhu233.github.io/kableExtra/). The two most common are simple tables and pipe tables. [You should look at the full documentation here](https://pandoc.org/MANUAL.html#tables). +::: {.callout-tip} +### Simple tables + **For simple tables, type…** -```text +```default Right Left Center Default ------- ------ ---------- ------- 12 12 12 12 @@ -214,10 +166,14 @@ Table: Caption goes here Table: Caption goes here +::: + +::: {.callout-tip} +### Pipe tables **For pipe tables, type…** -```text +```default | Right | Left | Default | Center | |------:|:-----|---------|:------:| | 12 | 12 | 12 | 12 | @@ -237,6 +193,7 @@ Table: Caption goes here Table: Caption goes here +::: ## Footnotes @@ -244,9 +201,12 @@ There are two different ways to add footnotes ([see here for complete documentat Regular notes need (1) an identifier and (2) the actual note. The identifier can be whatever you want. Some people like to use numbers like `[^1]`, but if you ever rearrange paragraphs or add notes before #1, the numbering will be wrong (in your Markdown file, not in the output; everything will be correct in the output). Because of that, I prefer to use some sort of text label: +::: {.callout-tip} +### Footnotes + **Type…** -```text +```default Here is a footnote reference[^1] and here is another [^note-on-dags]. [^1]: This is a note. @@ -271,13 +231,16 @@ And here's more of the document. > > ---- +::: You can also use inline footnotes with `^[Text of the note goes here]`, which are often easier because you don't need to worry about identifiers: +::: {.callout-tip} +### Inline footnotes + **Type…** -```text +```default Causal inference is neat.^[But it can be hard too!] ``` @@ -293,6 +256,8 @@ Causal inference is neat.^[But it can be hard too!] > > +::: + ## Front matter You can include a special section at the top of a Markdown document that contains metadata (or data about your document) like the title, date, author, etc. This section uses a special simple syntax named [YAML](https://learn.getgrav.org/16/advanced/yaml) (or "YAML Ain't Markup Language") that follows this basic outline: `setting: value for setting`. Here's an example YAML metadata section. Note that it must start and end with three dashes (`---`). @@ -361,18 +326,37 @@ One of the most powerful features of Markdown + pandoc is the ability to automat 3. Cite things in your document. [Check the documentation for full details of how to do this](https://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html). Essentially, you use `@citationkey` inside square brackets (`[]`): - | Type… | …to get… | - | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | - | `Causal inference is neat [@Rohrer:2018; @AngristPischke:2015].` | Causal inference is neat (Rohrer 2018; Angrist and Pischke 2015). | - | `Causal inference is neat [see @Rohrer:2018, p. 34; also @AngristPischke:2015, chapter 1].` | Causal inference is neat (see Rohrer 2018, 34; also Angrist and Pischke 2015, chap. 1). | - | `Angrist and Pischke say causal inference is neat [-@AngristPischke:2015; see also @Rohrer:2018].` | Angrist and Pischke say causal inference is neat (2015; see also Rohrer 2018). | - | `@AngristPischke:2015 [chapter 1] say causal inference is neat, and @Rohrer:2018 agrees.` | Angrist and Pischke (2015, chap. 1) say causal inference is neat, and Rohrer (2018) agrees. | - - After compiling, you should have a perfectly formatted bibliography added to the end of your document too: + +----------------------------------------------------+-------------------------------------------------+ + | Type... | ...to get... | + +====================================================+=================================================+ + | ``` default | Causal inference is neat (Rohrer 2018; | + | Causal inference is neat [@Rohrer:2018; | Angrist and Pischke 2015). | + | @AngristPischke:2015]. | | + | ``` | | + +----------------------------------------------------+-------------------------------------------------+ + | ``` default | Causal inference is neat (see Rohrer 2018, 34; | + | Causal inference is neat [see @Rohrer:2018, p. 34; | also Angrist and Pischke 2015, chap. 1). | + | also @AngristPischke:2015, chapter 1]. | | + | ``` | | + +----------------------------------------------------+-------------------------------------------------+ + | ``` default | Angrist and Pischke say causal inference is | + | Angrist and Pischke say causal inference is neat | neat (2015; see also Rohrer 2018). | + | [-@AngristPischke:2015; see also @Rohrer:2018]. | | + | ``` | | + +----------------------------------------------------+-------------------------------------------------+ + | ``` default | Angrist and Pischke (2015, chap. 1) say causal | + | @AngristPischke:2015 [chapter 1] say causal | inference is neat, and Rohrer (2018) agrees. | + | inference is neat, and @Rohrer:2018 agrees. | | + | ``` | | + +----------------------------------------------------+-------------------------------------------------+ + + : {tbl-colwidths="[50,50]"} + + After compiling, you should have a perfectly formatted bibliography added to the end of your document too: - > Angrist, Joshua D., and Jörn-Steffen Pischke. 2015. *Mastering ’Metrics: The Path from Cause to Effect.* Princeton, NJ: Princeton University Press. - > - > Rohrer, Julia M. 2018. “Thinking Clearly About Correlations and Causation: Graphical Causal Models for Observational Data.” *Advances in Methods and Practices in Psychological Science* 1 (1): 27–42. https://doi.org/10.1177/2515245917745629. + > Angrist, Joshua D., and Jörn-Steffen Pischke. 2015. *Mastering ’Metrics: The Path from Cause to Effect.* Princeton, NJ: Princeton University Press. + > + > Rohrer, Julia M. 2018. “Thinking Clearly About Correlations and Causation: Graphical Causal Models for Observational Data.” *Advances in Methods and Practices in Psychological Science* 1 (1): 27–42. https://doi.org/10.1177/2515245917745629. ## Other references @@ -383,3 +367,4 @@ These websites have additional details and examples and practice tools: - [**Markdown tutorial**](https://www.markdowntutorial.com/): Another interactive tutorial to practice using Markdown. - [**Markdown cheatsheet**](http://packetlife.net/media/library/16/Markdown.pdf): Useful one-page reminder of Markdown syntax. - [**The Plain Person’s Guide to Plain Text Social Science**](http://plain-text.co/): A comprehensive explanation and tutorial about why you should write data-based reports in Markdown. +