Appendix C — Markdown and YAML Reference Guide
Markdown describes content; YAML configures its processing. This appendix is a practical reference for academic reports, textbooks, websites and teaching materials. Examples are displayed as source rather than executed. Copy them into a separate practice document to experiment.
C.1 Document structure
A Quarto document consists of optional YAML metadata followed by Markdown content. Metadata describes the publication; headings describe the argument. Use one document title and a consistent hierarchy of sections. In a book chapter, the first level-one heading normally supplies the chapter title. Avoid manually numbering headings because the book renderer can supply numbering.
# Methods
## Study design
## Statistical analysisCreate a hierarchy for a clinic report with Methods and Results and two subsections under Methods.
C.2 Paragraphs and emphasis
Separate paragraphs with a blank line. A single newline generally does not create a new paragraph. Emphasis should signal meaning rather than substitute for headings. Inline code distinguishes a variable or command from prose. Escape punctuation with a backslash when it would otherwise be interpreted as markup.
The **primary outcome** was waiting time.
The variable `wait` is measured in minutes.
*Interpretation:* shorter waits are preferable.Format a variable name and emphasize the primary outcome.
C.3 Lists and quotations
Use numbered lists for procedures and bullets for unordered collections. Indent nested content consistently. A block quotation identifies quoted material, not merely a decorative paragraph. Cite the original source when quoting scholarly work.
1. Import the data.
2. Check missing values.
3. Summarize the observations.
- Mean
- Median
> An illustrative quotation.Write a three-step reproducibility procedure.
C.4 Links and images
Use descriptive link text rather than raw URLs. Image paths are normally relative to the source document. Use meaningful alternative text for informative images; a caption alone may not describe the visual pattern to a screen-reader user. Keep filenames simple and case consistent.
[Quarto documentation](https://quarto.org/docs/)
{#fig-wait fig-alt="Dot plot showing shorter waits in clinic B."}
See @fig-wait.Explain why a figure works locally but fails on a Linux host.
C.5 Tables
Pipe tables are useful for compact summaries. The separator row defines alignment; a colon on the right aligns numbers right. Include units in headings and explain missing values. For wide tables, consider a generated table or a simpler layout rather than shrinking text until unreadable.
| Clinic | Mean (min) | n |
|:-------|-----------:|--:|
| A | 16 | 5 |
| B | 12 | 5 |
: Observed waiting times. {#tbl-wait}
See @tbl-wait.Add a column for missing observations (A: 0, B: 1).
C.6 Mathematical notation
Use single dollar delimiters for inline mathematics and double dollar delimiters for display mathematics. LaTeX commands describe mathematical structure. Keep units in surrounding prose or use text within math. Equation identifiers permit references that survive renumbering.
The sample mean is $\bar{x}$.
$$
\bar{x}=\frac{1}{n}\sum_{i=1}^{n}x_i
$$ {#eq-mean}
Use @eq-mean to summarize observed values.Write the sample standard deviation using display mathematics.
C.7 Cross-references and citations
Identifiers for figures, tables, equations and sections use distinct prefixes. Use unique labels across a book. Bibliographic citations refer to keys in a bibliography file, whereas cross-references refer to objects inside the publication. Do not invent bibliographic records; verify author, title, year and identifier.
## Analysis {#sec-analysis}
See @sec-analysis and @fig-wait.
A parenthetical citation: [@quarto-docs].
A narrative citation: @quarto-docs.Distinguish a citation from a cross-reference.
C.8 Callouts and fenced divs
Quarto callouts provide semantic emphasis for notes, tips, warnings and important information. Fenced divs begin and end with colons. Use a longer outer fence when nesting. Do not rely on color alone to convey meaning.
::: {.callout-note title="Data quality"}
One waiting time is missing. Report the observed denominator.
:::
::: {.callout-tip}
Render from a clean session before submission.
:::Create a warning about confidential patient data.
C.9 Code listings and executable cells
A fenced block with a plain language name displays source code without executing it. Braces around the language name identify a computational cell. This distinction matters when writing a textbook: examples may be illustrative while standalone reports execute. Cell options beginning with #| belong at the start of executable cells.
```python
print(2 + 3)
```
```{python}
#| echo: true
print(2 + 3)
```
Predict the difference between these two blocks.
C.10 YAML fundamentals
YAML represents mappings, sequences and scalar values. Indentation defines nesting; use spaces rather than tabs. A colon followed by a space separates a key and value. Quote strings containing ambiguous punctuation, and avoid duplicate keys. Front matter is enclosed by three hyphens; a project configuration file has no enclosing delimiters.
title: "Clinic report: descriptive analysis"
author:
- name: Example Author
format:
html:
toc: true
code-fold: trueRepair a title containing an unquoted colon followed by a space.
C.11 Output formats
The format mapping can specify multiple outputs. HTML supports interactive browser features, whereas PDF and Word require static alternatives. PDF rendering generally requires a TeX installation. Inspect each format independently; a successful HTML render does not guarantee a successful PDF render.
format:
html:
toc: true
code-copy: true
pdf:
geometry: [margin=1in]
docx:
toc: trueAdd a table of contents to PDF output.
C.12 Execution options
Execution options control what readers see and whether computations run. Echo controls source visibility, not execution. Eval controls execution; include controls whether code and results appear. Keep error false for validation so failures stop the build. Suppressing warnings does not resolve their causes.
execute:
echo: true
warning: true
error: false
cache: falseHide code in a report while retaining results.
C.13 Project configuration
A project-level configuration supplies shared defaults. Document metadata can override many defaults. A book lists chapters in reading order; a website defines navigation. Keep independent examples in separate project directories and avoid accidentally rendering unrelated files.
project:
type: book
output-dir: _book
book:
title: Applied Mathematics
chapters:
- index.qmd
- models.qmd
format: htmlAdd a chapter called applications.qmd.
C.14 Troubleshooting and validation
Read the first meaningful error message rather than changing multiple settings at once. Validate YAML syntax, inspect relative paths, confirm computational engines, and render a minimal example. YAML parsing alone cannot establish that Quarto recognizes every option. Keep a known-good revision in Git.
quarto check
quarto render report.qmd --to html
quarto render report.qmd --to pdfDescribe a systematic response to a failed render.
C.15 Applied project: A reproducible clinic report
Create a report from the companion synthetic clinic dataset. Define the audience as a clinic quality-improvement team. Report observed counts, missing counts and mean waiting times by clinic. Include a labeled table, a labeled figure with alternative text, a displayed equation and a cross-reference to each object. Explain why the descriptive comparison does not establish causality. Render HTML and, if the required tools are installed, PDF or Word. Submit source, data, output and a README describing dependencies and render commands.
| Criterion | Points |
|---|---|
| Document hierarchy and readable prose | 5 |
| Correct YAML and computational settings | 5 |
| Accurate table, figure and equation | 5 |
| Cross-references and accessibility | 5 |
| Reproducibility and interpretation | 5 |
| Total | 25 |