Writing in Quarto

Learn the essential Quarto markdown syntax and formatting techniques to create professional, interactive documents for research and data science.

Key Takeaways
  • Quarto combines markdown text with code to create dynamic documents
  • Master basic formatting, code blocks, and callouts for effective communication
  • Use interactive features like tabsets and collapsible sections to organize content
  • Apply consistent styling across multiple output formats

What Makes Quarto Special?

Quarto lets you combine text, code, and visualizations in a single document. Write regular text and seamlessly include code that runs and displays results.

Text Formatting Essentials

Basic Text Styling

*This text is italic*
**This text is bold** 
***This text is bold and italic***
~~This text has strikethrough~~
`This is inline code`

This text is italic
This text is bold
This text is bold and italic
This text has strikethrough
This is inline code

Headers

# Main Title (H1)
## Section Header (H2)  
### Subsection Header (H3)
#### Smaller Header (H4)

Headers create structure and automatic navigation links.

Lists for Clear Organization

# Unordered Lists
* Research Design
* Data Collection
  + Phone Surveys
  + In-Person Interviews
* Data Analysis

# Ordered Lists
1. Design your survey
2. Collect pilot data
3. Refine your instrument
4. Launch full data collection

Unordered Lists * Research Design * Data Collection + Phone Surveys + In-Person Interviews * Data Analysis

Ordered Lists 1. Design your survey 2. Collect pilot data 3. Refine your instrument 4. Launch full data collection

Code Blocks

# Simple code display
```
summary(data)
mean(variable)
```

# With syntax highlighting
```python
import pandas as pd
df = pd.read_csv("data.csv")
print(df.head())
```

# Executable code cells

::: {#6a701b50 .cell execution_count=1}
``` {.python .cell-code}
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
plt.plot(x, y)
plt.show()
```

::: {.cell-output .cell-output-display}
![](basics_files/figure-html/cell-2-output-1.png){width=566 height=411}
:::
:::

Simple Code Display:

summary(data)
mean(variable)

With Syntax Highlighting:

import pandas as pd
df = pd.read_csv("data.csv")
print(df.head())

Executable cells run code and show output in your document.

Callouts

::: {.callout-note}
This is a standard note callout.
:::

::: {.callout-tip title="Pro Tip"}  
Always pilot your survey before deployment!
:::

::: {.callout-warning}
Remember to back up your data.
:::

::: {.callout-important appearance="simple"}
IRB approval required before data collection.
:::

::: {.callout-caution collapse="true"}
## Potential Issues
Click to expand details...
:::
Note

This is a standard note callout.

Pro Tip

Always pilot your survey before deployment!

Warning

Remember to back up your data.

IRB approval required before data collection.

Click to expand details…

Tabsets

::: {.panel-tabset}

## Survey Methods
- Phone surveys
- In-person interviews  
- Online questionnaires

## Analysis Tools  
- Stata for statistical analysis
- R for data visualization
- Python for machine learning

## Best Practices
- Always clean your data
- Document your methodology
- Version control your code
:::
  • Phone surveys
  • In-person interviews
  • Online questionnaires
  • WhatsApp surveys
  • Stata for statistical analysis
  • R for data visualization
  • Python for machine learning
  • Excel for basic calculations
  • Always clean your data
  • Document your methodology
  • Version control your code
  • Share reproducible results

Custom Styling

::: {.border}
This content has a border around it.
:::

::: {.custom-summary-block}
This matches the site's summary block styling.
:::

This content has a border around it.

This matches the site’s summary block styling.

Mathematical Expressions

# Inline math
The formula $E = mc^2$ is famous.

# Block equations
$$
\text{Treatment Effect} = \bar{Y}_{\text{treatment}} - \bar{Y}_{\text{control}}
$$

Inline math: The formula \(E = mc^2\) is famous.

Block equations: \[ \text{Treatment Effect} = \bar{Y}_{\text{treatment}} - \bar{Y}_{\text{control}} \]

Tables

| Survey Type | Response Rate | Cost per Response |
|-------------|---------------|-------------------|
| Phone       | 65%           | $12               |
| In-person   | 85%           | $45               |
| WhatsApp    | 78%           | $3                |
Survey Type Response Rate Cost per Response
Phone 65% $12
In-person 85% $45
WhatsApp 78% $3

Next Steps

  • Create Professional Documents: Combine these elements for research reports and analysis guides
  • Customize Your Style: Add a brand.yml file for consistent styling Learn more
  • Share Your Work: Publish to GitHub Pages, Netlify, or other platforms
  • Collaborate: Use version control with Git to track changes
Ready to Practice?

Try creating your own Quarto document using these elements. Start simple with headers, text formatting, and a callout, then add more complex features.

Learning Resources

Official Documentation

Interactive Tutorials

Examples and Inspiration

Video Resources

Extensions and Tools

Community

Back to top