latex-tables
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLaTeX Tables with tabularray
使用tabularray制作LaTeX表格
When to Use This Skill
何时使用该技能
Use this skill when:
- Creating tables with fixed-width columns
- Formatting complex table layouts
- Need precise column alignment
- Migrating from tabular/tabularx/longtable/booktabs
- Troubleshooting table overflow issues
当你需要以下操作时使用该技能:
- 创建带固定宽度列的表格
- 格式化复杂表格布局
- 需要精确的列对齐
- 从tabular/tabularx/longtable/booktabs迁移
- 解决表格溢出问题
Quick Reference
快速参考
Why tabularray?
为什么选择tabularray?
Modern LaTeX3 package (replaces old solutions):
- Fixed-width columns with proper alignment
- Clean, consistent syntax
- Replaces: ,
tabular,tabularx,longtablebooktabs - Better performance than legacy packages
- Part of TeX Live 2025
现代LaTeX3包(替代旧解决方案):
- 支持固定宽度列且对齐方式合理
- 简洁、一致的语法
- 可替代:、
tabular、tabularx、longtablebooktabs - 比传统包性能更优
- 已纳入TeX Live 2025
Installation
安装
bash
undefinedbash
undefinedCheck if installed
Check if installed
kpsewhich tabularray.sty
kpsewhich tabularray.sty
If not found, install:
If not found, install:
sudo tlmgr install tabularray
undefinedsudo tlmgr install tabularray
undefinedBasic Usage
基础用法
latex
\documentclass{article}
\usepackage{tabularray} % Modern table package
\begin{document}
% Simple table
\begin{tblr}{colspec={ccc}, hlines, vlines}
Header 1 & Header 2 & Header 3 \\
Data 1 & Data 2 & Data 3 \\
\end{tblr}
\end{document}latex
\documentclass{article}
\usepackage{tabularray} % Modern table package
\begin{document}
% Simple table
\begin{tblr}{colspec={ccc}, hlines, vlines}
Header 1 & Header 2 & Header 3 \\
Data 1 & Data 2 & Data 3 \\
\end{tblr}
\end{document}Quick Reference Card
快速参考卡片
latex
% Minimal table
\begin{tblr}{colspec={ccc}}
A & B & C \\
\end{tblr}
% With all lines
\begin{tblr}{colspec={ccc}, hlines, vlines}
A & B & C \\
\end{tblr}
% Fixed widths
\begin{tblr}{colspec={Q[2cm] Q[3cm] Q[2cm]}, hlines}
A & B & C \\
\end{tblr}
% Bold header
\begin{tblr}{
colspec={ccc},
row{1}={font=\bfseries}
}
Header & Header & Header \\
Data & Data & Data \\
\end{tblr}latex
% Minimal table
\begin{tblr}{colspec={ccc}}
A & B & C \\
\end{tblr}
% With all lines
\begin{tblr}{colspec={ccc}, hlines, vlines}
A & B & C \\
\end{tblr}
% Fixed widths
\begin{tblr}{colspec={Q[2cm] Q[3cm] Q[2cm]}, hlines}
A & B & C \\
\end{tblr}
% Bold header
\begin{tblr}{
colspec={ccc},
row{1}={font=\bfseries}
}
Header & Header & Header \\
Data & Data & Data \\
\end{tblr}Best Practices
最佳实践
- Use Q[width] for fixed columns instead of p{width}
- Specify widths explicitly when text might overflow
- Use X for flexible columns that should expand
- Style headers with row{1} instead of manual formatting
- Use colspec for column properties, not inline commands
- Check package version: (should be recent)
kpsewhich tabularray.sty
- 使用Q[width]定义固定列,替代p{width}
- 当文本可能溢出时,显式指定宽度
- 使用X定义可灵活扩展的列
- 使用row{1}设置表头样式,替代手动格式化
- 使用colspec定义列属性,而非行内命令
- 检查包版本:(需为最新版本)
kpsewhich tabularray.sty
Reference Documentation
参考文档
For detailed information, see:
- Table Patterns - 5 common table patterns with examples
- Column Specification - Alignment options and width control
- Lines and Borders - All lines, selective lines, thick lines
- Troubleshooting - Table too wide, text not wrapping, alignment issues
- Migration - Migrating from tabular and tabularx
Official Docs: Run for complete package documentation
texdoc tabularraySee Also:
- Use skill for installing tabularray package
latex/setup - Use skill for compilation workflows
latex/build
如需详细信息,请查看:
- 表格模式 - 5种常见表格模式及示例
- 列规格说明 - 对齐选项与宽度控制
- 线条与边框 - 全线条、选择性线条、粗线条
- 问题排查 - 表格过宽、文本不换行、对齐问题
- 迁移指南 - 从tabular和tabularx迁移
官方文档:运行查看完整包文档
texdoc tabularray另请参阅:
- 使用技能安装tabularray包
latex/setup - 使用技能了解编译工作流
latex/build
Troubleshooting
问题排查
| Issue | Cause | Solution |
|---|---|---|
| Package not found | tabularray not installed | |
| Table too wide | Fixed widths exceed page | Use smaller Q[width] values or X for flexible |
| Text not wrapping | Column spec missing width | Use Q[width] instead of c/l/r for wrapping |
| Alignment issues | Mixed column types | Ensure all columns have consistent spec |
| Compile error on colspec | Invalid syntax | Check for missing commas or typos in column spec |
| hlines not appearing | Missing from spec | Add |
| Row style not applied | Wrong row index | Remember row{1} is first row (1-indexed) |
| Package version too old | TeX Live outdated | |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 未找到包 | 未安装tabularray | |
| 表格过宽 | 固定宽度超出页面范围 | 使用更小的Q[width]值,或用X定义灵活列 |
| 文本不换行 | 列规格未指定宽度 | 使用Q[width]替代c/l/r以实现换行 |
| 对齐问题 | 列类型混合使用 | 确保所有列的规格一致 |
| colspec编译错误 | 语法无效 | 检查列规格中是否缺少逗号或拼写错误 |
| hlines未显示 | 规格中未包含 | 在规格中添加 |
| 行样式未应用 | 行索引错误 | 记住row{1}是第一行(从1开始索引) |
| 包版本过旧 | TeX Live已过时 | |