LaTeX 表格的基本单元是 tabular:先声明每一列怎么对齐,再一行行填单元格。论文里更推荐 三线表booktabs),而不是满屏竖线。

最小例子

\begin{table}[htbp]
  \centering
  \caption{算法时间复杂度对比}
  \label{tab:complexity}
  \begin{tabular}{cc}
    \hline
    Algorithm & Time complexity \\
    \hline
    RM-MEDA  & $O(NM)$ \\
    IRM-MEDA & $O(NK)$ \\
    \hline
  \end{tabular}
\end{table}

列格式:

更推荐的三线表

\usepackage{booktabs}

\begin{table}[htbp]
  \centering
  \caption{算法时间复杂度对比}
  \label{tab:complexity}
  \begin{tabular}{ll}
    \toprule
    Algorithm & Time complexity \\
    \midrule
    RM-MEDA  & $O(NM)$ \\
    IRM-MEDA & $O(NK)$ \\
    \bottomrule
  \end{tabular}
\end{table}

\toprule \midrule \bottomrule 线宽层次更符合排版规范。

合并单元格

\multicolumn{2}{c}{Overall} \\

多行合并用 multirow 宏包。

浮动体位置

[htbp] 是建议位置:here / top / bottom / page。不要迷信 [h] 一定「就在这」——LaTeX 会整体优化。大表可用 table*(双栏模板)。

常见错误

  1. \caption 放在 tabular 外、table 内(正确);放反会报错或编号乱。
  2. \label 必须在 \caption 之后
  3. 单元格里的 _ 要进数学模式 $O(N_m)$
  4. 超宽表:换 p{}tabularx 或缩小 \small

下一步

小结

先掌握 tabular + table + caption,再换成 booktabs 三线表,就覆盖了 80% 的论文表格需求。简单,但是要写对浮动与引用。

单元格内换行与宽度

egin{tabular}{p{4cm}c}
长文本会在固定宽度内换行 & 短 \
\end{tabular}

引用表格

正文写:见表~ ef{tab:complexity}。编译需 两次 才能解析引用。

掌握最小表后,再学 booktabsmultirowlongtable 即可覆盖绝大多数论文表。