![如何获得每个单元格都有一个角切的表格?](https://linux22.com/image/460935/%E5%A6%82%E4%BD%95%E8%8E%B7%E5%BE%97%E6%AF%8F%E4%B8%AA%E5%8D%95%E5%85%83%E6%A0%BC%E9%83%BD%E6%9C%89%E4%B8%80%E4%B8%AA%E8%A7%92%E5%88%87%E7%9A%84%E8%A1%A8%E6%A0%BC%EF%BC%9F.png)
答案1
{NiceTabular}
这是使用的解决方案nicematrix
。该环境类似于{tabular}
(包 的array
)标准,但还会在行、列和单元格下创建 PGF/Tikz 节点。然后,可以将这些节点与 Tikz 一起使用。在下面的代码中,我使用 Tikz 和这些节点创建小的白色三角形。
\documentclass{article}
\usepackage{nicematrix,tikz,ifthen}
\begin{document}
\renewcommand{\arraystretch}{1.2}
\begin{NiceTabular}{cccc}[hvlines-except-borders,rules={color=white,width=1pt}]
\CodeBefore
\rowcolor{red!15}{1}
\rowcolor{blue!15}{2-}
\Body
some text & other & other & other \\
some text & other & other & other \\
some text & other & other & other \\
some text & other & other & other \\
\CodeAfter
\begin{tikzpicture}[color = white]
\foreach \i in {2,...,\inteval{\value{iRow}+1}}
{
\foreach \j in {2,...,\inteval{\value{jCol}+1}}
{
% for technical reasons, the last column needs a special treatment:
% we translate by the width of the rules
\ifthenelse{\j>\value{jCol}}
{ \fill ([xshift=1pt]\i-|\j) -- ++ (0,2mm) -- ++ (-2mm,-2mm) -- cycle ; }
{ \fill (\i-|\j) -- ++ (0,2mm) -- ++ (-2mm,-2mm) -- cycle ; }
}
}
\end{tikzpicture}
\end{NiceTabular}
\end{document}
您需要多次编译(因为 PGF/Tikz 节点)。