Writing in Quarto
This guide covers the basics of writing in Quarto, including text formatting, code blocks, callouts, and tabsets.
Learn the essential Quarto markdown syntax and formatting techniques to create professional, interactive documents for research and data science.
- 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 collectionUnordered 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
::: {#875a924e .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}
{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...
:::This is a standard note callout.
Always pilot your survey before deployment!
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
Links and Images
# Links
[Visit IPA's website](https://poverty-action.org)
[Quarto Documentation](https://quarto.org/docs/)
# Images
{width=75%}Links: Visit IPA’s website and Quarto Documentation
Images: 
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 |
| 78% | $3 |
Next Steps
- Create Professional Documents: Combine these elements for research reports and analysis guides
- Customize Your Style: Add a
brand.ymlfile 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
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
- Quarto Guide - Comprehensive documentation covering all features
- Authoring Guide - Deep dive into markdown and content creation
- Publishing Guide - How to share your documents online
Interactive Tutorials
- Hello, Quarto - Quick start tutorial for VS Code
- Computations - Learn to embed code and outputs
- Authoring - Advanced formatting and features
Examples and Inspiration
- Quarto Gallery - Showcase of real-world Quarto projects
- Awesome Quarto - Community-curated list of resources
Video Resources
- Introduction to Quarto - Overview and key features
- Academic Workflows with Quarto - Research-focused examples
Extensions and Tools
- Quarto Extensions - Add functionality with community extensions
- VS Code Extension - Enhanced editing experience
Community
- Quarto Discussions - Ask questions and share tips
- RStudio Community - Active forum for Quarto users