I adapted a solution from post Multi-colored cell background using Overleaf.
The code I use is the following:
%%% This code comes from https://tex.stackexchange.com/questions/348933/multi-colored-cell-background with minor adjustments regarding the format of the table %%%
\documentclass{article}
\usepackage{colortbl}
\usepackage{tikz}
\usepackage{nicematrix}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\makeatletter
\tikzset{
double color fill/.code 2 args={
\pgfdeclareverticalshading[%
tikz@axis@top,tikz@axis@middle,tikz@axis@bottom%
]{diagonalfill}{100bp}{%
color(0bp)=(tikz@axis@bottom);
color(50bp)=(tikz@axis@bottom);
color(50bp)=(tikz@axis@middle);
color(50bp)=(tikz@axis@top);
color(100bp)=(tikz@axis@top)
}
\tikzset{shade, left color=#1, right color=#2, shading=diagonalfill}
}
}
\makeatother
\tikzset{%
diagonal fill/.style 2 args={%
double color fill={#1}{#2},
shading angle=45,
opacity=0.8},
other filling/.style={%
shade,
shading=myshade, % myshade is defined below
shading angle=0,
opacity=0}
}
\noindent\begin{NiceTabular}{| p{0.25\textwidth}
|p{0.02\textwidth}*{3}{|p{0.02\textwidth}}
|p{0.02\textwidth}*{3}{|p{0.02\textwidth}}
|p{0.02\textwidth}*{3}{|p{0.02\textwidth}}
|p{0.02\textwidth}*{3}{|p{0.02\textwidth}}
|}
\hline
\textbf{Lorem}
& \multicolumn{4}{c|}{dolor}
& \multicolumn{4}{c|}{sit}
& \multicolumn{4}{c|}{amet}
& \multicolumn{4}{c|}{beneficae} \\ \cline{2-17}
\hline
\hline
\textbf{ipsum} & \multicolumn{4}{c|}{} & \multicolumn{4}{c|}{} & \multicolumn{4}{c|}{} & \multicolumn{4}{c|}{} \\
\hline
Lorem ipsum dolor sit amet & \Block[tikz={diagonal fill={yellow}{green}}]{}{} & \Block[tikz={diagonal fill={yellow}{green}}]{}{} & & \\
\hline
\end{NiceTabular}
\end{document}
In contrast to the original post, the two colors are not strictly separated, but they have a gradient, even though I am very sure I am using the same code. I'd like to get rid of this gradient, can anyone help me with that ?
Thanks a lot!


