diagbox宏包定义了几种表格线样式,能满足基本需求。但是对于复杂的表格斜线就有些难以实现了,能否定义一个更自由的画线命令,通过平移左上角和右下角的坐标实现画线自由?
你可以用 nicematrix
,它能够使用 tikz 绘制复杂表格(不能跨页)。
\documentclass{ctexart}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{nicematrix}
\usetikzlibrary{intersections,patterns,decorations.pathmorphing}
\begin{document}
\begin{NiceTabular}{>{\centering}p{2cm}p{2cm}p{2cm}c}[hvlines,
create-large-nodes,left-margin,right-margin]
\Block{2-3}{~} & & & 什么?\\
~ &~ &~ & \Block{1-1}{wh\\at?} \\
1 & 2 & 3 & 4
\CodeAfter
\begin{tikzpicture}
\draw[pattern=north west lines] ([xshift=-1em,yshift=1em]3-4-large.north west) rectangle ([xshift=1pt,yshift=-.5pt]3-4-large.south east);
\path[fill=red!30] ([xshift=1em-1pt]1-1-large.north west) arc (0:-90:1em) --([xshift=-1pt]1-1-large.north west) --cycle;
\draw (1-1-large.north west)-- node[midway,below left=-2pt]{看看} (2-2-large.south west);
\draw[decorate,decoration={snake}] (1-1-large.north west)-- node[pos=0.6,below left=-2.5pt]{第二} (2-3-large.south west);
\draw (1-1-large.north west)-- node[near end,below left]{上下} (1-4-large.south west);
\path[name path=a] (1-1-large.north west)--(2-4-large.south west);
\draw[name path=b] (3-3-large.north west)--(1-4-large.south west);
\draw[name intersections={of=a and b, name=itr}] (itr-1)-- node[pos=.4,above right=-2pt]{what} (3-4-large.north west);
\draw[dashed] (1-1-large.north west)--(itr-1);
\draw (itr-1)--(3-1-large.north west);
\end{tikzpicture}
\end{NiceTabular}
\end{document}
感谢大佬,但我使用的是tabularray宏包排版表格