SuperAPI AI Directory

latex-table

Writing & research

View repository

Updated 10-15 18:46

About this skill

latex-table — LaTeX regression table generation Skill

This Skill assists in generating LaTeX regression tables that conform to the formatting standards of **top economics journals (AER, QJE, Econometrica, JPE)**. It covers: standard three-line tables, panel data fixed effects tables, instrumental variable tables, and event study tables.

Applicable scenarios

  • Need to insert standardized regression result tables in paper writing
  • Convert Stata/Python/R output to LaTeX code
  • Format three-line tables according to journal requirements
  • Generate Main Table + Online Appendix Table

Core concepts

Core elements of top journal tables:

  1. Clear information hierarchy——Table header, groups, and variable names progress layer by layer
  2. Complete statistical information——Sample size, standard errors, clustering level, R², F statistic
  3. Standardized significance annotation——Unified stars (†///)
  4. Reproducible——Table code must correspond to regression code

Standard three-line table formatting specifications

Top journal table structure

┌─────────────────────────────────────────────┐
│  表头(表标题 + 注释信息)                      │
├─────────────────────────────────────────────┤
│  列标签(列1    列2    列3)                  │
│  ──────────────────────────────────────────  │ ← 第一道线(顶部)
│  变量行(因变量、自变量、控制变量)              │
│  ──────────────────────────────────────────  │ ← 第二道线(列分隔)
│  统计量行(N、R²、F、聚类标准误)              │
├─────────────────────────────────────────────┤
│  表底注释(显著性标注、数据来源、稳健性说明)     │
└─────────────────────────────────────────────┘

Significance star standards

Symbol p-value Description
*** p < 0.001 1% significance
** p < 0.01 5% significance
* p < 0.05 10% significance
† p < 0.10 15% significance (some journals)

⚠️ Note: Different journals have different requirements for the number of stars and thresholds. Before submission, confirm the format of the target journal.

Common table LaTeX templates

Template 1: Standard OLS regression table

\begin{table}[htbp]
  \centering
  \caption{基准回归结果}
  \label{tab:baseline}
  \begin{threeparttable}
    \begin{tabular}{l*{3}{c}}
      \toprule
      & \multicolumn{3}{c}{因变量: log(GDP per capita)} \\
      \cmidrule(l){2-4}
      & (1) & (2) & (3) \\
      \midrule
      互联网普及率 & 0.023*** & 0.018** & 0.015* \\
                  & (0.007) & (0.008) & (0.008) \\
      控制变量     & 否       & 是       & 是       \\
      固定效应     & 否       & 否       & 年份+国家\\
      \midrule
      观测值       & 1,240    & 1,240    & 1,240    \\
      R²          & 0.041    & 0.315    & 0.682    \\
      \bottomrule
    \end{tabular}
    \begin{tablenotes}
      \item \textit{注:} ***, **, * 分别表示1\%, 5\%, 10\%的显著性水平。括号内为聚类标准误(聚类在国家层面)。控制变量包括:教育年限、人口增长率、贸易开放度。
    \end{tablenotes}
  \end{threeparttable}
\end{table}

Template 2: Panel data fixed effects table

\begin{table}[htbp]
  \centering
  \caption{固定效应模型估计结果}
  \label{tab:fe}
  \begin{threeparttable}
    \begin{tabular}{l*{4}{c}}
      \toprule
      & \multicolumn{2}{c}{OLS} & \multicolumn{2}{c}{固定效应} \\
      \cmidrule(l){2-3} \cmidrule(l){4-5}
      & (1) & (2) & (3) & (4) \\
      \midrule
      技术扩散指数 & 0.035*** & 0.028** & 0.021* & 0.018* \\
                   & (0.009) & (0.010) & (0.011) & (0.010) \\
      \midrule
      国家固定效应   & \checkmark & \checkmark & \checkmark & \checkmark \\
      年份固定效应   &            & \checkmark &            & \checkmark \\
      \midrule
      观测值         & 1,240 & 1,240 & 1,240 & 1,240 \\
      R²             & 0.31  & 0.45  & 0.72  & 0.78  \\
      \bottomrule
    \end{tabular}
    \begin{tablenotes}
      \item \textit{注:} 同上。固定效应模型使用双向聚类标准误(国家+年份)。
    \end{tablenotes}
  \end{threeparttable}
\end{table}

Template 3: Instrumental variable method table

\begin{table}[htbp]
  \centering
  \caption{工具变量估计结果}
  \label{tab:iv}
  \begin{threeparttable}
    \begin{tabular}{l*{3}{c}}
      \toprule
      & OLS & \multicolumn{2}{c}{2SLS} \\
      \cmidrule(l){2-2} \cmidrule(l){3-4}
      & (1) & (2) & (3) \\
      \midrule
      技术扩散指数 & 0.023*** & 0.041*** & 0.038*** \\
                  & (0.007) & (0.013) & (0.012) \\
      \midrule
      KP F统计量   &         & 24.6     & 28.3     \\
      弱工具变量检验 &         &          &          \\
      \midrule
      观测值       & 1,240   & 1,240    & 1,240    \\
      \bottomrule
    \end{tabular}
    \begin{tablenotes}
      \item \textit{注:} 列(2)-(3)使用技术扩散的滞后值作为工具变量。KP F统计量>10通过弱工具变量检验。
    \end{tablenotes}
  \end{threeparttable}
\end{table}

Conversion tools from Stata/Python/R to LaTeX

Stata → LaTeX

// 安装 estout 套件
ssc install estout, replace

// 保存回归结果
eststo clear
eststo: reg ln_gdp internet i.year, vce(cluster country)
eststo: reg ln_gdp internet cov1 cov2 i.year, vce(cluster country)

// 导出 LaTeX
esttab using "tables/table1.tex", replace ///
  title("基准回归结果") ///
  label ///
  booktabs ///
  nonumbers ///
  mtitles("OLS" "OLS") ///
  star(* 0.05 ** 0.01 *** 0.001) ///
  se ///
  r2 ///
  addn("控制变量包括教育年限、人口增长率、贸易开放度。")

Python (statsmodels) → LaTeX

import pandas as pd
from scipy.stats import ttest_ind

# 使用 statsmodels 输出的 LaTeX 转换
from statsmodels.iolib.summary import summary_table

# 回归后
result = model.fit()
print(result.summary_latex())

Three-line table formatting specifications (top journal requirements)

Requirement Description
Threeparttable Use \begin{threeparttable} environment
booktabs Use \toprule, \midrule, \bottomrule
Font Usually 10pt; table notes can be 9pt
Column width Use p{3cm} to control column width, or tabularx to adjust automatically
Number alignment Numbers right-aligned, variable name column left-aligned
Missing values Indicate missing values in the table with blank spaces, do not write "NA"

Output specifications

## 表格输出规范

**输出路径**:tables/table{N}.tex
**主子表规范**:
- 主表(Main):表格1-3,放入正文
- 附录表(Appendix):表格A1-A10,放入Online Appendix

**文件名规范**:

tables/table1_baseline.tex # Baseline regression tables/table2_heterogeneity.tex # Heterogeneity analysis tables/tableA1_robustness_iv.tex # Appendix: IV robustness


**LaTeX 代码规范**:
- 表格必须可编译(无缺失 `}` 或 `{`)
- 所有特殊字符(%, &, #)需转义

Invocation interface

Enter in the Claude Code conversation window:

/latex-table

Or complete Prompt:

按LaTeX表格Skill生成符合AER顶刊格式的三线表回归结果,包括:基准回归表(表1)、固定效应表(表2)、工具变量表(表3)。使用booktabs环境,包含标准误聚类标注、显著性星标、固定效应标注。

Coordination with other Skills

  • did-reviewer → DID regression results use the event study table format
  • R-optimizer → Optimization when R outputs tables
  • codebook-pass → Cleaned data is used directly for table generation

Important statement

  • Tables must be reproducible——The regressions corresponding to the LaTeX table code must be re-runnable via Makefile
  • Before submission, the star threshold and table size must be adjusted according to the target journal's format.
  • Separation of main and subordinate tables—Place the core results in the main table, and put robustness and heterogeneity in the appendix.