我希望我的表格有分隔的单元格。基本上是双线,但我不知道如何断开水平线。我试过 \hline 和 \cline,但它们也连接在一起。
这是我能做的最好的事情:
\begin{tabular}{|c||c||c||c|}
\hline
\multicolumn{2}{|c||}{First Cell}&
Second Cell&
Third Cell\\
\hline
\hline
\begin{tabular}{@{}l@{}} Data\\ Data\\ Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}\\
\hline
\end{tabular}
答案1
您可以使用线包裹:
\documentclass{article}
\usepackage{hhline}
\begin{document}
\begin{tabular}{|c||c||c||c|}
\hhline{|--||-||-|}
\multicolumn{2}{|c||}{First Cell}&
Second Cell&
Third Cell\\
\hhline{=:t:=::=::=:}
\begin{tabular}{@{}l@{}} Data\\ Data\\ Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}\\
\hhline{=::=::=::=:}
More data &
More data &
More data &
More data\\
\hhline{|-||-||-||-|}
\end{tabular}
\end{document}
答案2
\documentclass{article}
\usepackage{array,hhline}
\begin{document}
\setlength\extrarowheight{2pt}
\begin{tabular}{|c||c||c||c|}
\hhline{|--||-||-|}
\multicolumn{2}{|c||}{First Cell}&
Second Cell&
Third Cell\\
\hhline{=:t:=::=::=}
\begin{tabular}{@{}l@{}} Data\\ Data\\ Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}&
\begin{tabular}{@{}l@{}}
Data\\
Data\\
Data\\
\end{tabular}\\
\hhline{|-||-||-||-|}
\end{tabular}
\end{document}
答案3
{NiceTabular}
以下是使用构建该表的一种方法nicematrix
。
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
\renewcommand{\arraystretch}{1.3}
\begin{NiceTabular}{cccc}
\Block{1-2}{First Cell} && Second Cell & Third cell \\
\Block{3-1}{} Data & \Block{3-1}{} Data & \Block{3-1}{} Data & \Block{3-1}{} Data \\
Data & Data & Data & Data \\
Data & Data & Data & Data \\
More Data & More Data & More Data & More Data \\
\CodeAfter
\TikzEveryCell{offset=1pt,draw}
\end{NiceTabular}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。
也可以添加圆角:
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
\renewcommand{\arraystretch}{1.3}
\begin{NiceTabular}{cccc}
\Block{1-2}{First Cell} && Second Cell & Third cell \\
\Block{3-1}{} Data & \Block{3-1}{} Data & \Block{3-1}{} Data & \Block{3-1}{} Data \\
Data & Data & Data & Data \\
Data & Data & Data & Data \\
More Data & More Data & More Data & More Data \\
\CodeAfter
\TikzEveryCell{offset=1pt,draw,rounded corners}
\end{NiceTabular}
\end{document}