我想在我的表中嵌套两个框。它看起来像这样:
content content content content content
+----------------------+
content | content content | content content
|+--------------------+|
content ||content content|| content content
|+--------------------+|
content | content content | content content
+----------------------+
content content content content content
我在看在表格中框定单元格这提供了一个很好的解决方案,但主要问题是我无法设置内部框中水平线的长度。\cline{2-3}
总是产生相同的宽度。它会产生如下所示的内容:
content content content content content
+----------------------+
content | content content | content content
++--------------------++
content ||content content|| content content
++--------------------++
content | content content | content content
+----------------------+
content content content content content
但我想避免内框与外框相交/连接。
答案1
对于练习和起点:
\documentclass[border=3mm,
tikz,
preview
]{standalone}
\usetikzlibrary{fit,
matrix,
}
\begin{document}
\begin{tikzpicture}[
every node/.style = {inner sep=0.5mm}
]
\matrix (magic) [matrix of nodes,
column sep=1.5mm,
row sep=1.5mm]
{
content & content & content & content & content \\
content & content & content & content & content \\
content & content & content & content & content \\
content & content & content & content & content \\
content & content & content & content & content \\
};
\node (a) [draw, fit=(magic-3-2) (magic-3-3)] {};
\node (b) [draw, fit=(magic-2-2) (a) (magic-4-3)] {};
\end{tikzpicture}
\end{document}
如何在您的表格中执行此操作?首先,您需要提供包含表格的完整文档,这样我才能看到可以做什么。上面的图片仅复制了您有问题的图片 :-)
答案2
{NiceTabular}
这是的解决方案nicematrix
。该环境类似于经典环境{tabular}
(由 提供array
),但在单元格、行和列下创建 PGF/TikZ 节点。然后可以将这些节点与 TikZ 一起使用来绘制您想要的任何规则。
\documentclass{article}
\usepackage{nicematrix,tikz}
\begin{document}
\begin{NiceTabular}{ccccc}
content & content & content & content & content \\
content & content & content & content & content \\
content & content & content & content & content \\
content & content & content & content & content \\
content & content & content & content & content \\
\CodeAfter
\tikz \draw (1-|1) rectangle (last-|last)
(2-|2) rectangle (5-|4)
([xshift=2pt]3-|2) rectangle ([xshift=-2pt]4-|4) ;
\end{NiceTabular}
\end{document}