latex-tables
> Generates publication-ready LaTeX tables produced by code (Stata `esttab`/`outreg2`, R `modelsummary`/`fixest::etable`, Python `stargazer`/`pyfixest.etable`) and writes them directly to the paper's `tabs/` folder. Defaults to DIME's 'full replicability' standard (no copy-paste from any console), `
- License 许可
- MIT
- 最近更新
- 2026-11-09
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- latex-tables
- risk
- low
- source
- https://github.com/JonasWeinert/EconAgentSkills
- license
- MIT
- version
- 1.0.0
- category
- economics
- description
- > Generates publication-ready LaTeX tables produced by code (Stata `esttab`/`outreg2`, R `modelsummary`/`fixest::etable`, Python `stargazer`/`pyfixest.etable`) and writes them directly to the paper's `tabs/` folder. Defaults to DIME's 'full replicability' standard (no copy-paste from any console), `
- imported_at
- 2026-09-20
- source_path
- _skills/writing/latex-tables/SKILL.md
- source_repository
- JonasWeinert/EconAgentSkills
- disable-model-invocation
- false
02 资源文件 7
- 其他examples/make_tables_esttab.do3.9 KB
- 其他examples/make_tables_modelsummary.R2.4 KB
- 脚本examples/make_tables_pyfixest.py1.8 KB
- 脚本examples/make_tables_stargazer.py1.5 KB
- 其他examples/table_balance_template.tex1.3 KB
- 其他examples/table_main_template.tex1.3 KB
- 参考文档reference.md10.3 KB
03 SKILL.md 正文
LaTeX Tables
Generate publication-ready LaTeX tables that come out of code (esttab, modelsummary, pyfixest.etable, stargazer) and \input{} cleanly into the paper. The default style follows DIME's "full replicability" tier: no manual editing between code and PDF.
Operating Principles
- Tables are produced, never typed. DIME identifies four levels of replicability: full, good, basic, and none. "None" (copy-paste from a console window) is unacceptable for any output that leaves the analyst. Default to full: code writes a
.texfile that the paper\input{}s directly. - One source of truth per table. Every numeric cell, star, sample size, and footnote comes from the same script that ran the regression. Never edit the
.texfile by hand — re-run the script and rebuild the paper. booktabsstyling. Three horizontal rules (\toprule,\midrule,\bottomrule), no vertical lines, consistent decimal alignment viasiunitxScolumns when precision matters.- Notes via
threeparttable. Significance levels, standard-error type, sample restrictions, and clustering belong in a single notes block at the bottom — not in the caption. - Cross-reference with
\Cref{}.\label{tab:main}+\Cref{tab:main}reads "Table 2" in body text and behaves correctly at sentence start.
Decision Policy
This skill follows the repo-wide Agent Policy.
ASK before proceeding (blocking):
- Source language of the regression (Stata / R / Python) — determines the canonical table package.
- Table type (regression / summary stats / balance / multi-panel / DiD-estimator comparison).
- Standard-error type and cluster level (these belong in the table notes).
- Output target (LaTeX
.tex, Word.rtf, Excel.xlsx).
DEFAULT + flag (use this default; tell the user how to override):
esttab(Stata),modelsummaryorfixest::etable(R),pyfixest.etableorstargazer(Python).booktabsstyling:\toprule,\midrule,\bottomrule; no vertical lines.- Three-star convention
* 0.10 ** 0.05 *** 0.01; pin once per paper. threeparttablefor the notes block.- Output path
paper/tabs/<name>.tex; the paper\input{}s it. - Within-R² (
r2_within) reported instead of overall R² for FE models.
DOCUMENT and proceed (write into the decisions log of the table-generating script):
- The estimating equation, sample, cluster level, and FE included for each column.
- Variable label mapping (
coef_map/coeflabels). - Any subsample restriction shown in a column.
PROCEED items: tables produced by code (never copy-paste); generated .tex never hand-edited; rebuild path runs the table script before LaTeX.
Pre-flight Checklist
Before generating code, confirm with the user — and write the answers in the script header:
- Source language. Stata, R, or Python? (Each has its own canonical table package.)
- Table type. Regression (multi-spec), summary statistics, balance / difference-in-means, descriptive cross-tabs, or model-comparison panel?
- Sample. Single or stratified? If panel, which fixed effects are on/off across columns?
- Standard errors. Cluster-robust at which level? Wild-bootstrap p-values?
- Stars and notes. Conventional
*** ** *cutoffs (1/5/10), or journal-specific (some require none)? - Output path. Almost always
paper/tabs/{name}.tex; the paper\input{}s that file. - Compile target.
\begin{table}floating environment in body, or nakedtabularsnippet to be included from a parent macro?
Decision Tree (which table package to use)
Source = Stata
└── esttab (from estout) is canonical.
eststo store; esttab using "tabs/x.tex", booktabs label se ...
Source = R
├── fixest models (most common in 2024-26): use fixest::etable
└── Mixed model classes: use modelsummary (works across lm, glm,
PanelOLS, fixest, brms, ...). modelsummary writes .tex via
`output = "tabs/x.tex"`.
Source = Python
├── pyfixest models: use pyfixest.etable
├── linearmodels models: use compare(...) + manual to_latex(), or
pass models through stargazer
└── statsmodels OLS / GLM: use stargazer (Python port).
Output for Word
└── Same packages with .rtf or .docx output (esttab supports rtf;
modelsummary supports docx via flextable).
Output Path Convention
paper/
├── paper.tex
├── tabs/ # all .tex tables; never hand-edited
│ ├── table_main.tex
│ ├── table_balance.tex
│ ├── table_summary.tex
│ └── table_robustness.tex
├── figs/
└── code/
├── stata/
│ └── make_tables.do
└── r/
└── make_tables.R
Body text:
\Cref{tab:main} reports our preferred specification.
\input{tabs/table_main.tex}
The .tex file should produce the entire \begin{table} ... \end{table} environment so you only have one \input{} per table in the paper.
Common Pitfalls
- Hand-editing the
.texfile after generation. The next run will overwrite or diverge from the published numbers. - Mixing significance-star conventions across tables (
*at 0.05 in one, at 0.10 in another). - Using
\hlineeverywhere; readers expect three-linebooktabstables. - Vertical lines in regression tables — never necessary, always ugly.
- Putting key information in the caption (e.g. "Standard errors clustered by firm") instead of in the notes block, where it can be longer and less awkward.
- Using
_in variable labels without\_escaping; LaTeX silently interprets them as subscripts. - Including raw column names like
treat_postinstead of human-readable labels. - Numbers with inconsistent decimal precision across columns.
- Missing N row at the bottom of regression tables; reviewers will ask.
- Not exporting at all — running the regression in interactive mode and screenshotting the result. (This is "no replicability" in DIME's framework.)
Additional Resources
reference.md— extended patterns: balance tables, summary stats, panel tables, threeparttable notes, siunitx S-column alignment, multi-panel tables, journal-specific deviations.examples/— runnable scripts that produce real.texfiles:examples/make_tables_esttab.do— Stata regression + summary + balance viaesttabexamples/make_tables_modelsummary.R— R viamodelsummary+fixest::etableexamples/make_tables_pyfixest.py— Python viapyfixest.etableexamples/make_tables_stargazer.py— Pythonstatsmodelsviastargazerexamples/table_main_template.tex— minimal copy-paste-able tabular for "good replicability" casesexamples/table_balance_template.tex— DIME-style balance table layout
Requirements
- LaTeX: TeX Live 2022+ or MacTeX 2022+; packages
booktabs,threeparttable,siunitx,caption,cleveref. - Stata:
ssc install estout(providesesttab,eststo,estadd,estpost). - R:
install.packages(c("modelsummary", "fixest", "kableExtra")). - Python:
pip install stargazer pyfixest pandas.
References
DIME
- DIME Analytics, Exporting Analysis — four levels of replicability.
- DIME Analytics, Checklist: Submit Table.
- DIME Analytics, Stata Coding Practices —
estoutfamily.
Style
- AEA, Manuscript Style Guide.
- Jansen & Persson, Nice and fast tables in Stata for LaTeX and Excel — https://osf.io/78nuc/.
- Lukas Püttmann,
esttabcheat sheet. booktabsdocumentation — https://ctan.org/pkg/booktabs.siunitx— https://ctan.org/pkg/siunitx (S columns for decimal alignment).
04 同仓库更多 Skills
dei-assessment
Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.
dei-action-plan
Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.
culture-fit-assessment
Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.
cowork-to-code-bridge
Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.
counter-offer-response
Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.
continuous-feedback-system
Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.