Tables and Figures
Overview
This skill produces publication-quality tables and figures that are regenerated by scripts, not hand-edited. Tables use booktabs for professional rules and threeparttable for integrated notes. Figures are vector PDFs — PNG and JPG are forbidden in the final paper. Every table and figure comes from a script under code/ and is included in the paper via \input{} or \includegraphics{}.
When to Use
- "Make a table of descriptive statistics"
- "Format the regression results for the paper"
- "Create a figure showing X over time"
- "Generate the event-study plot"
- Preparing final outputs for submission
- Re-running the analysis after data changes
Mandatory Steps
Generate every table and figure from a script in code/ that reads from data/processed/ and writes to output/tables/ or output/figures/. Never hand-edit the output file.
Use booktabs rules in tables. \toprule, \midrule, \bottomrule. Never \hline. Never vertical bars.
Wrap every table in threeparttable with a notes block documenting: standard error type, significance convention, sample, data source.
Save figures as vector PDF. Use ggplot2 with ggsave(..., device = cairo_pdf) in R, or matplotlib.pyplot.savefig(..., format='pdf') in Python. Raster formats (PNG, JPG) are forbidden in the final paper.
Include in the paper with \input{} or \includegraphics{}. Never paste numbers or copy images.
Use the naming convention:
- Tables:
tab_<purpose>.tex — tab_descriptives.tex, tab_main_results.tex, tab_robustness.tex
- Figures:
fig_<purpose>.pdf — fig_event_study.pdf, fig_trends.pdf
Table notes and figure captions follow the user's paper language. The file names and script comments stay in English; the user-facing text in the notes and captions follows the paper's language setting.
No table may overflow the text width. After generating a table, verify it fits within \linewidth. If it overflows:
- First, reduce column padding with
@{} column separators or \setlength{\tabcolsep}{3pt}.
- Second, abbreviate column headers or use multi-row headers.
- Third, use
\resizebox{\linewidth}{!}{...} — but only if font remains readable.
- Last resort: switch the table page to landscape using the
pdflscape package (\begin{landscape}...\end{landscape}). Add \usepackage{pdflscape} to the preamble.
Never let a table bleed into the margin. After compilation, check for Overfull \hbox warnings on table lines and fix them.
Table Template
Standard regression results table:
\begin{table}[htbp]
\centering
\begin{threeparttable}
\caption{Main Results}
\label{tab:main}
\begin{tabular}{lcc}
\toprule
& (1) & (2) \\
& OLS & FE \\
\midrule
Treatment & 0.123*** & 0.098** \\
& (0.034) & (0.041) \\
\midrule
N & 10{,}234 & 10{,}234 \\
R$^2$ & 0.42 & 0.58 \\
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\footnotesize
\item \textit{Notes:} Standard errors clustered at the state level in parentheses. * p$<$0.10, ** p$<$0.05, *** p$<$0.01. Sample covers 2010--2020. Data: IBGE PNADC.
\end{tablenotes}
\end{threeparttable}
\end{table}
Required packages in paper preamble:
\usepackage{booktabs}
\usepackage{threeparttable}
Significance Convention
Default: * p<0.10, ** p<0.05, *** p<0.01 (economics and finance convention).
Alternative: * p<0.05, ** p<0.01, *** p<0.001 (common in psychology and medicine).
Detect the convention by reading CLAUDE.superpapers.md from the current working directory, or walking up parent directories until found, and using the significance_convention field. If the file is absent or the field is unset, ask the user — do not silently default. Always document the convention in the table note; do not assume the reader knows which convention is used.
Figure Standards
- Format: Vector PDF only. No PNG, JPG, or other raster formats in the final paper.
- Generator: ggplot2 in R (preferred) or matplotlib/seaborn in Python, or native LaTeX via tikz/pgfplots.
- Theme:
theme_minimal() or theme_classic() in ggplot2, with adjustments for print. Avoid grey backgrounds from ggplot2's default theme.
- Colors: Colorblind-safe palettes (
viridis, RColorBrewer Dark2 or Set1). For B&W print compatibility, use dash patterns or shapes rather than relying on color alone.
- Titles: Do not embed plot titles in the figure. The title goes in the LaTeX caption.
- Axis labels: Clear, with units (
Unemployment rate (%), Year, Real GDP (log)).
- Legend: Minimal. Remove if only one series.
- Saving:
ggsave("output/figures/fig_name.pdf", width = W, height = H, device = cairo_pdf).
Example figure code (R/ggplot2):
library(ggplot2)
p <- ggplot(data, aes(x = year, y = unemployment, color = region)) +
geom_line(linewidth = 0.8) +
scale_color_viridis_d(option = "D") +
labs(x = "Year", y = "Unemployment rate (%)", color = NULL) +
theme_minimal(base_size = 11) +
theme(
legend.position = "bottom",
panel.grid.minor = element_blank()
)
ggsave(
"output/figures/fig_unemployment.pdf",
plot = p,
width = 6.5, height = 4,
device = cairo_pdf
)
Anti-Patterns
- Tables using
\hline instead of booktabs rules
- Tables with vertical bars (
|)
- Tables without a notes block
- Figures saved as PNG or JPG in the final paper
- Hand-edited
.tex table files
- Significance convention undocumented in the note
- Figures with embedded titles clashing with LaTeX captions
- Missing sample description in the table note
- Using ggplot2's default grey background theme in published figures
- Color-only differentiation in figures intended for B&W print
- Tables that overflow into the page margin without correction
- Using
\resizebox as a first resort instead of redesigning column layout or reducing padding
- Wide tables left in portrait when landscape would preserve readability
Verification Before Completion
1---2name: tables-and-figures3description: Use when generating a LaTeX results table, creating a figure for a paper, formatting descriptive statistics, preparing regression output for publication, or producing vector-quality graphics. Enforces booktabs, threeparttable, vector PDFs, and script-generated output.4---56# Tables and Figures78## Overview910This skill produces publication-quality tables and figures that are regenerated by scripts, not hand-edited. Tables use `booktabs` for professional rules and `threeparttable` for integrated notes. Figures are vector PDFs — PNG and JPG are forbidden in the final paper. Every table and figure comes from a script under `code/` and is included in the paper via `\input{}` or `\includegraphics{}`.1112## When to Use1314- "Make a table of descriptive statistics"15- "Format the regression results for the paper"16- "Create a figure showing X over time"17- "Generate the event-study plot"18- Preparing final outputs for submission19- Re-running the analysis after data changes2021## Mandatory Steps22231. **Generate every table and figure from a script** in `code/` that reads from `data/processed/` and writes to `output/tables/` or `output/figures/`. Never hand-edit the output file.24252. **Use booktabs rules in tables.** `\toprule`, `\midrule`, `\bottomrule`. Never `\hline`. Never vertical bars.26273. **Wrap every table in `threeparttable`** with a notes block documenting: standard error type, significance convention, sample, data source.28294. **Save figures as vector PDF.** Use ggplot2 with `ggsave(..., device = cairo_pdf)` in R, or `matplotlib.pyplot.savefig(..., format='pdf')` in Python. Raster formats (PNG, JPG) are forbidden in the final paper.30315. **Include in the paper with `\input{}` or `\includegraphics{}`.** Never paste numbers or copy images.32336. **Use the naming convention:**34 - Tables: `tab_<purpose>.tex` — `tab_descriptives.tex`, `tab_main_results.tex`, `tab_robustness.tex`35 - Figures: `fig_<purpose>.pdf` — `fig_event_study.pdf`, `fig_trends.pdf`36377. **Table notes and figure captions follow the user's paper language.** The file names and script comments stay in English; the user-facing text in the notes and captions follows the paper's language setting.38398. **No table may overflow the text width.** After generating a table, verify it fits within `\linewidth`. If it overflows:40 - First, reduce column padding with `@{}` column separators or `\setlength{\tabcolsep}{3pt}`.41 - Second, abbreviate column headers or use multi-row headers.42 - Third, use `\resizebox{\linewidth}{!}{...}` — but only if font remains readable.43 - Last resort: switch the table page to landscape using the `pdflscape` package (`\begin{landscape}...\end{landscape}`). Add `\usepackage{pdflscape}` to the preamble.44 Never let a table bleed into the margin. After compilation, check for `Overfull \hbox` warnings on table lines and fix them.4546## Table Template4748Standard regression results table:4950```latex51\begin{table}[htbp]52\centering53\begin{threeparttable}54\caption{Main Results}55\label{tab:main}56\begin{tabular}{lcc}57\toprule58 & (1) & (2) \\59 & OLS & FE \\60\midrule61Treatment & 0.123*** & 0.098** \\62 & (0.034) & (0.041) \\63\midrule64N & 10{,}234 & 10{,}234 \\65R$^2$ & 0.42 & 0.58 \\66\bottomrule67\end{tabular}68\begin{tablenotes}[flushleft]69\footnotesize70\item \textit{Notes:} Standard errors clustered at the state level in parentheses. * p$<$0.10, ** p$<$0.05, *** p$<$0.01. Sample covers 2010--2020. Data: IBGE PNADC.71\end{tablenotes}72\end{threeparttable}73\end{table}74```7576Required packages in paper preamble:7778```latex79\usepackage{booktabs}80\usepackage{threeparttable}81```8283## Significance Convention8485**Default:** `* p<0.10, ** p<0.05, *** p<0.01` (economics and finance convention).8687**Alternative:** `* p<0.05, ** p<0.01, *** p<0.001` (common in psychology and medicine).8889Detect the convention by reading `CLAUDE.superpapers.md` from the current working directory, or walking up parent directories until found, and using the `significance_convention` field. If the file is absent or the field is unset, ask the user — do not silently default. Always document the convention in the table note; do not assume the reader knows which convention is used.9091## Figure Standards9293- **Format:** Vector PDF only. No PNG, JPG, or other raster formats in the final paper.94- **Generator:** ggplot2 in R (preferred) or matplotlib/seaborn in Python, or native LaTeX via tikz/pgfplots.95- **Theme:** `theme_minimal()` or `theme_classic()` in ggplot2, with adjustments for print. Avoid grey backgrounds from ggplot2's default theme.96- **Colors:** Colorblind-safe palettes (`viridis`, `RColorBrewer` Dark2 or Set1). For B&W print compatibility, use dash patterns or shapes rather than relying on color alone.97- **Titles:** Do not embed plot titles in the figure. The title goes in the LaTeX caption.98- **Axis labels:** Clear, with units (`Unemployment rate (%)`, `Year`, `Real GDP (log)`).99- **Legend:** Minimal. Remove if only one series.100- **Saving:** `ggsave("output/figures/fig_name.pdf", width = W, height = H, device = cairo_pdf)`.101102Example figure code (R/ggplot2):103104```r105library(ggplot2)106107p <- ggplot(data, aes(x = year, y = unemployment, color = region)) +108 geom_line(linewidth = 0.8) +109 scale_color_viridis_d(option = "D") +110 labs(x = "Year", y = "Unemployment rate (%)", color = NULL) +111 theme_minimal(base_size = 11) +112 theme(113 legend.position = "bottom",114 panel.grid.minor = element_blank()115 )116117ggsave(118 "output/figures/fig_unemployment.pdf",119 plot = p,120 width = 6.5, height = 4,121 device = cairo_pdf122)123```124125## Anti-Patterns126127- Tables using `\hline` instead of booktabs rules128- Tables with vertical bars (`|`)129- Tables without a notes block130- Figures saved as PNG or JPG in the final paper131- Hand-edited `.tex` table files132- Significance convention undocumented in the note133- Figures with embedded titles clashing with LaTeX captions134- Missing sample description in the table note135- Using ggplot2's default grey background theme in published figures136- Color-only differentiation in figures intended for B&W print137- Tables that overflow into the page margin without correction138- Using `\resizebox` as a first resort instead of redesigning column layout or reducing padding139- Wide tables left in portrait when landscape would preserve readability140141## Verification Before Completion142143- [ ] Every table and figure generated by a script in `code/`144- [ ] Outputs in `output/tables/` or `output/figures/`145- [ ] Tables use `booktabs` and `threeparttable`146- [ ] Significance convention documented in every results table note147- [ ] Figures are vector PDFs148- [ ] No titles embedded in figures149- [ ] Axis labels and units specified150- [ ] Colors colorblind-safe where feasible151- [ ] Table notes and figure captions in the user's paper language152- [ ] No table overflows the text width or bleeds into margins153- [ ] Wide tables use landscape orientation or column optimization to remain readable