答案1
有 colortbl 包,但对于\cline
s,我建议使用 NiceTabular 环境好矩阵包,或者使用 tabularray 包的类似功能。
使用 nicematrix:
\documentclass{article}
% for color models
\usepackage{xcolor}
% for nice coloring in tables
\usepackage{nicematrix}
% for multi-row cells
\usepackage{multirow}
%for Helvetica-like sans font
\usepackage[T1]{fontenc}
\usepackage{tgheros}
\begin{document}
\sffamily
% adds some vertical padding in cells
\renewcommand{\arraystretch}{1.5}
% slightly thicker lines
\setlength{\arrayrulewidth}{0.8pt}
\begin{NiceTabular}{|p{1.5cm}|p{1.5cm}|p{6cm}|}[colortbl-like]
\hline
\rowcolor{yellow} Step 1 & 1 & xx \\
\hline
\rowcolor[HTML]{d4f0dc} Step 2 & 2 & xx \\
\hline
\rowcolor[HTML]{b7e0ff} Step 3 & \multirow{4}*{3} & xx\\
\cline{1-1}\cline{3-3}
\rowcolor[HTML]{b7e0ff} Step 4 & & xx \\
\cline{1-1}\cline{3-3}
\rowcolor[HTML]{b7e0ff}Step 5 & & xx\\
\cline{1-1}\cline{3-3}
\rowcolor[HTML]{b7e0ff}Step 6 & & xx\\
\hline
\rowcolor[HTML]{92d050} Step 7 & 1 & xx\\
\hline
\end{NiceTabular}
\end{document}
随着表格数组包(完全相同的输出):
\documentclass{article}
% for color models
\usepackage{xcolor}
% for nice coloring in tables
\usepackage{tabularray}
% for multi-row cells
\usepackage{multirow}
%for Helvetica-like sans font
\usepackage[T1]{fontenc}
\usepackage{tgheros}
\begin{document}
\sffamily
% adds some vertical padding in cells
\renewcommand{\arraystretch}{1.5}
% slightly thicker lines
\setlength{\rulewidth}{0.8pt}
% define colors
\definecolor{mycyan}{HTML}{d4f0dc}
\definecolor{myblue}{HTML}{b7e0ff}
\definecolor{mygreen}{HTML}{92d050}
\begin{tblr}{
colspec={|p{1.5cm}|p{1.5cm}|p{6cm}|},
}
\hline
\SetRow{yellow}
Step 1 & 1 & xx \\
\hline
\SetRow{mycyan}
Step 2 & 2 & xx \\
\hline
\SetRow{myblue}
Step 3 & \SetCell[r=4]{wd=1.5cm}{3} & xx\\
\cline{1-1}\cline{3-3}
\SetRow{myblue}
Step 4 & & xx \\
\cline{1-1}\cline{3-3}
\SetRow{myblue}
Step 5 & & xx\\
\cline{1-1}\cline{3-3}
\SetRow{myblue}
Step 6 & & xx\\
\hline
\SetRow{mygreen}
Step 7 & 1 & xx\\
\hline
\end{tblr}
\end{document}
答案2
frabjous 已提供解决方案nicematrix
。有关信息,这里有一种更简短的方法来使用创建表格nicematrix
。
\documentclass{article}
% for color models
\usepackage{xcolor}
\definecolor{mycyan}{HTML}{b7e0ff}
% for nice coloring in tables
\usepackage{nicematrix}
%for Helvetica-like sans font
\usepackage[T1]{fontenc}
\usepackage{tgheros}
\begin{document}
\sffamily
% adds some vertical padding in cells
\renewcommand{\arraystretch}{1.5}
% slightly thicker lines
\setlength{\arrayrulewidth}{0.8pt}
\begin{NiceTabular}{p{1.5cm}p{1.5cm}p{6cm}}[colortbl-like,hvlines]
\rowcolor{yellow} Step 1 & 1 & xx \\
\rowcolor[HTML]{d4f0dc} Step 2 & 2 & xx \\
\RowStyle[nb-rows=4,rowcolor=mycyan]{}
Step 3 & \Block[l]{4-1}{3} & xx\\
Step 4 & & xx \\
Step 5 & & xx \\
Step 6 & & xx \\
\rowcolor[HTML]{92d050} Step 7 & 1 & xx\\
\end{NiceTabular}
\end{document}