latex 表格合并单元格换行

时间:2022-01-26 20:31:10

表格示例

\begin{table}[h]
  \centering
  \caption{} \label{}
  \begin{tabular}{c|c|c}
     \hline   %  or \cline{col1-col2}
     * & * & * \\
     * & * & *
  \end{tabular}
\end{table}

 

标题居中

\usepackage[justification=centering]{caption}

or

\centering

\begin{center}  ...  \end{center}

表格放大缩小

\scalebox{0.8}{
  \begin{tabular}{ccc}
  ...
  \end{tabular}
}

单元格内换行

\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}

\begin{table}[!htb]
  \centering
  \caption{*}\label{*}
  \begin{tabular}{ccc}
     \hline
     *  &  \tabincell{c}{*\\*}  &  \\
     *  &           *                   &  \\
  \end{tabular}
\end{table}

合并单元格:

%合并列
    *  &  *  &  *  &  *  \\
    \multicolumn{3}{|c|}{*}  &  

%合并行
\usepackage{multirow}
    *  &  *  &  *  &  *  \\
    \multirow{2}{c}{*}  &  *  &  *  &  *  \\ \cline{2-3}    
                                    &  *  &  *  &  *  \\

行列同时合并

    *  &  *  &  *  &  *  \\
    \multicolumn{2}{c}{\multirow{2}{*}{*}}  &  *  &  *  &  *  \\ \cline{1-1}\cline{4-4}    
    \multicolumn{2}{c}{}                                 & *  &  *  &  *  \\