latex-tables

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LaTeX Tables

LaTeX 表格

Purpose

用途

This skill creates clean, publication-ready tables in LaTeX for regression results and summary statistics, using standard academic formatting.
本技能按照标准学术格式,为回归结果和描述性统计生成整洁的、可直接用于发表的LaTeX表格。

When to Use

适用场景

  • Converting model output into LaTeX tables
  • Standardizing table style across a paper
  • Adding notes, significance stars, and labels
  • 将模型输出转换为LaTeX表格
  • 统一整篇论文的表格样式
  • 添加注释、显著性星号和标签

Instructions

使用说明

Follow these steps to complete the task:
按照以下步骤完成任务:

Step 1: Understand the Context

步骤1:理解上下文

Before generating any code, ask the user:
  • What type of table is needed (regression, summary stats, balance)?
  • What software produced the results (Stata, R, Python)?
  • Which formatting style is required (journal-specific, AEA, etc.)?
生成任何代码前,先询问用户:
  • 需要什么类型的表格(回归、描述性统计、平衡性检验?)
  • 结果是由什么软件生成的(Stata、R、Python?)
  • 需要哪种格式规范(特定期刊要求、AEA规范等?)

Step 2: Generate the Output

步骤2:生成输出

Based on the context, generate LaTeX code that:
  1. Uses
    booktabs
    for clean horizontal rules
  2. Includes labels and captions for referencing in the paper
  3. Adds notes for standard errors and significance
  4. Aligns numeric columns for readability
基于上下文,生成满足以下要求的LaTeX代码:
  1. 使用
    booktabs
    生成整洁的水平分隔线
  2. 包含标签和标题 以便在论文中引用
  3. 添加注释 说明标准误和显著性含义
  4. 数值列对齐 提升可读性

Step 3: Verify and Explain

步骤3:验证与说明

After generating output:
  • Explain how to compile the table
  • Highlight any assumptions in the formatting
  • Suggest refinements for journal submission
生成输出后:
  • 说明如何编译表格
  • 点明格式中用到的所有假设
  • 为期刊提交提出优化建议

Example Prompts

示例提问

  • "Create a regression table with three models in LaTeX"
  • "Format summary statistics with mean and sd columns"
  • "Add significance stars and standard error notes"
  • "用LaTeX生成包含三个模型的回归表格"
  • "格式化包含均值和标准差列的描述性统计结果"
  • "添加显著性星号和标准误注释"

Example Output

输出示例

latex
% ============================================
% Regression Table
% ============================================
\begin{table}[htbp]\centering
\caption{Effect of Treatment on Outcome}
\label{tab:main_results}
\begin{tabular}{lccc}
\toprule
 & (1) & (2) & (3) \\
\midrule
Treatment & 0.125*** & 0.118*** & 0.102** \\
 & (0.041) & (0.039) & (0.046) \\
Controls & No & Yes & Yes \\
Fixed Effects & No & Yes & Yes \\
\midrule
Observations & 2,145 & 2,145 & 2,145 \\
R-squared & 0.18 & 0.24 & 0.31 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item Notes: Standard errors in parentheses. * p<0.10, ** p<0.05, *** p<0.01.
\end{tablenotes}
\end{table}
latex
% ============================================
% Regression Table
% ============================================
\begin{table}[htbp]\centering
\caption{Effect of Treatment on Outcome}
\label{tab:main_results}
\begin{tabular}{lccc}
\toprule
 & (1) & (2) & (3) \\
\midrule
Treatment & 0.125*** & 0.118*** & 0.102** \\
 & (0.041) & (0.039) & (0.046) \\
Controls & No & Yes & Yes \\
Fixed Effects & No & Yes & Yes \\
\midrule
Observations & 2,145 & 2,145 & 2,145 \\
R-squared & 0.18 & 0.24 & 0.31 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item Notes: Standard errors in parentheses. * p<0.10, ** p<0.05, *** p<0.01.
\end{tablenotes}
\end{table}

Requirements

依赖要求

Software

软件

  • LaTeX distribution (TeX Live or MikTeX)
  • LaTeX发行版(TeX Live 或 MikTeX)

Packages

宏包

  • booktabs
  • threeparttable
    (optional for notes)
  • booktabs
  • threeparttable
    (添加注释时可选)

Best Practices

最佳实践

  1. Keep tables compact and readable
  2. Use consistent notation for standard errors and stars
  3. Provide clear captions and labels
  1. 保持表格紧凑易读
  2. 标准误和显著性星号使用统一的标注规范
  3. 提供清晰的标题和标签

Common Pitfalls

常见问题

  • Overly wide tables that do not fit the page
  • Missing notes for standard errors
  • Inconsistent labeling across tables
  • 表格过宽超出页面范围
  • 缺少标准误相关注释
  • 表格间标签命名不一致

References

参考资料

Changelog

更新日志

v1.0.0

v1.0.0

  • Initial release
  • 首次发布