答案1
这里是;
\documentclass{article}
\usepackage{array, multirow}
\begin{document}
\setlength{\extrarowheight}{3pt}
\begin{tabular}{ | c | c | c |}
\hline
\multirow{2}{*}{A} & \multicolumn{2}{c |}{B} \\ \cline{2-3}
& C & D \\ \hline
\multicolumn{2}{|c|}{\multirow{2}{*}{E}} & G1 \\ \cline{3-3}
\multicolumn{2}{|c|}{} & G2 \\ \hline
\end{tabular}
\end{document}
答案2
该nicematrix
包正好适合这个Block
命令
\documentclass{standalone}
\usepackage{nicematrix}
\usepackage{multirow}
\begin{document}
\begin{NiceTabular}{|c|c|c|}
\hline
\Block{2-1} {A} & \Block{1-2} {B} & \\ \cline{2-3}
& C & D \\ \hline
\Block{2-2} {E} & & G1 \\ \cline{3-3}
& & G2 \\
\hline
\end{NiceTabular}
\end{document}
答案3
\documentclass[12pt]{article}
\usepackage{multirow}
\begin{document}
\begin{table}
\begin{tabular}{|c|c|c|}
\hline
\multirow{2}{*}{A} & \multicolumn{2}{c|}{B} \\ \cline{2-3}
& C & D \\ \hline
\multicolumn{2}{|c|}{\multirow{2}{*}{E}} & G1 \\ \cline{3-3}
\multicolumn{2}{|c|}{} & G2 \\ \hline
\end{tabular}
\end{table}
\end{document}
答案4
tblr
环境的替代解决方案tabularray
包裹:
\documentclass[12pt]{article}
\usepackage{tabularray}
\begin{document}
Old Interfaces:
\begin{tblr}{|c|c|c|}
\hline
\SetCell[r=2]{m} A & \SetCell[c=2]{c} B & \\ \cline{2-3}
& C & D \\ \hline
\SetCell[r=2,c=2]{m,c} E & & G1 \\ \cline{3-3}
& & G2 \\ \hline
\end{tblr}
\qquad
New Interfaces:
\begin{tblr}{
colspec = {|c|c|c|},
hlines,
cell{1}{1} = {r=2}{m}, % multorow
cell{1}{2} = {c=2}{c}, % multicolumn,
cell{3}{1} = {r=2,c=2}{m,c}, % multirow and multicolumn
}
A & B & \\
& C & D \\
E & & G1 \\
& & G2 \\
\end{tblr}
\end{document}