Agent skill
bookdown
Cross-referencing in R Markdown documents using bookdown. Use when creating Rmd files that need references to figures, tables, equations, or sections. Triggers on requests for academic reports, technical documents, or any R Markdown with numbered cross-references.
Install this agent skill to your Project
npx add-skill https://github.com/CodingKaiser/kaiser-skills/tree/main/bookdown
SKILL.md
Bookdown Cross-Referencing
Output Formats
Use bookdown:: output formats for cross-referencing support:
output:
bookdown::html_document2:
toc: true
bookdown::pdf_document2:
toc: true
Other formats: gitbook, word_document2, epub_book.
Figures
Chunk name becomes the reference ID. Requires fig.cap:
```{r myplot, fig.cap="Distribution of values."}
plot(x)
Reference: `Figure \@ref(fig:myplot)` → "Figure 1"
### Long Captions (Text Reference)
Define caption outside chunk, reference inside:
```markdown
(ref:myplot) This is a very long caption with **markdown** and citations [@smith2020].
```{r myplot, fig.cap="(ref:myplot)"}
plot(x)
## Tables
Use `knitr::kable()` with `caption`:
```r
```{r mytable}
knitr::kable(df, caption = "Summary statistics.")
Reference: `Table \@ref(tab:mytable)` → "Table 1"
## Sections
Headers auto-generate IDs from text (lowercase, hyphens):
```markdown
# My Analysis Section
See Section \@ref(my-analysis-section).
Custom ID: # My Section {#custom-id}
Equations
\begin{equation}
y = mx + b
(\#eq:linear)
\end{equation}
See Equation \@ref(eq:linear).
Quick Reference
| Element | Chunk/Label | Reference Syntax |
|---|---|---|
| Figure | myplot |
\@ref(fig:myplot) |
| Table | mytable |
\@ref(tab:mytable) |
| Section | my-section |
\@ref(my-section) |
| Equation | eq:model |
\@ref(eq:model) |
Common Issues
- References show as
??: Missingfig.capor wrong output format - Duplicate labels: Each chunk name must be unique
- Backslash required: Use
\@ref()not@ref()
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
general-agentic
snakemake-compact
Compact Snakemake workflow patterns. Keep rules short, complex logic in Python modules.
plotly
Plotly visualization patterns for statistical and scientific charts. Use when creating interactive visualizations, statistical plots (scatter, box, violin, heatmaps), UpSet plots for set intersections, network graphs, or exporting figures to HTML/PNG/PDF/SVG formats. Covers both Plotly Express (high-level) and Graph Objects (low-level) APIs.
marimo-compact
Compact marimo notebook patterns. Reactive cells, UI elements, data visualization.
python-cli-patterns
CLI application patterns for Python. Triggers on: cli, command line, typer, click, argparse, terminal, rich, console, terminal ui.
r-development
Modern R development practices emphasizing tidyverse patterns (dplyr 1.1 and later, native pipe, join_by, .by grouping), rlang metaprogramming, performance optimization, and package development. Use when you needs to write R code, create R packages, optimize R performance, or provide R programming guidance.
Didn't find tool you were looking for?