答案1
重新绘制线条并不困难。您只需要足够合适的 \tikzmark/\pgfmarks——您可以使用一些计数器自动创建它们。您甚至可以在设置它们绘制背景之前在 tikz 命令中使用它们。在具有自动换行符的设置中,您应该将 -commands 放在\tikz
单元格内,以使它们不会因分页符而与标记分开。
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\tikz[overlay,remember picture]\fill[yellow,] ({pic cs:tabstart} |- {pic cs:a1}) rectangle ({pic cs:tabend} |- {pic cs:a2});
\tikzmark{tabstart}%
\begin{tabular}{l}
abcxxxxxxxxxxxxxxx \\\noalign{\pgfmark{a1}}
aa\rule[-1cm]{4pt}{2.5cm}xxxxxxxx\\\noalign{\pgfmark{a2}}
\end{tabular}%
\tikzmark{tabend}
\tikz[overlay,remember picture]\draw[red,] ({pic cs:tabstart} |- {pic cs:a1}) --({pic cs:tabend} |- {pic cs:a1});
\tikz[overlay,remember picture]\draw[green,]({pic cs:tabstart} |- {pic cs:a2}) --({pic cs:tabend} |- {pic cs:a2});
\end{document}