我想在D,E,F,G
单元格之间添加水平分割线。我尝试\hline
在末尾添加,但它会分割整条线。多行单元格C
不应分割。
\documentclass{standalone}
\usepackage{tikz}
\usepackage{multirow}
\begin{document}
\begin{tikzpicture}[font=\tiny]
\node[] (A) {
\begin{tabular}{|c|c|} \hline
\multicolumn{2}{|c|}{{A}} \\ \hline
\multicolumn{2}{|c|}{{B}} \\ \hline
\multirow{4}{*}{C} & D \\
& E \\
& F \\
& G \\ \hline
\end{tabular}
};
\end{tikzpicture}
\end{document}
答案1
如果你对强大的tabularray
\documentclass[border=1pt]{standalone}
\usepackage{tikz}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\begin{document}
\begin{tikzpicture}[font=\tiny]
\node (A) {
\begin{tblr}{
colspec = {|c|c|},
row{1-2} = {font=\bfseries},
hlines,
}
\SetCell[c=2]{c} A \\
\SetCell[c=2]{c} B \\
\SetCell[r=4]{c} C & D \\
& E \\
& F \\
& G \\
\end{tblr}
};
\end{tikzpicture}
\end{document}