2

How can I make a color gradient in a table from the first row to the last row (from top to bottom)?

\documentclass[]{article}
\usepackage{tabularray}
\usepackage{xcolor}
\begin{document}

\begin{tblr}{
  width = \linewidth,
  colspec = {Q[165]Q[165]Q[165]Q[165]},
  cells = {c},
  row{1} = {blue!50},
  row{2} = {cyan!50},
  hlines,
  vlines}
 a & B & C & D \\
one & two & three & noone
\end{tblr}

\end{document}
1

1 Answer 1

3

Here is an example with {NiceTabular} of nicematrix with a row by row color gradient (you need several compilations).

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{NiceTabular}{c}
\CodeBefore
   \definecolorseries{BlueWhite}{rgb}{last}{blue}{white}
   \resetcolorseries[\value{iRow}]{BlueWhite}
   \rowlistcolors{1}{BlueWhite!!+}
\Body
Mathilde \\
Pierre \\
Paul \\
Amélie \\
Jacques \\
Antoine \\
Stéphanie \\
\end{NiceTabular}

\end{document}

Output of the first code

Here is an example with a continuous gradient (Tikz must be loaded).

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}

\begin{NiceTabular}{c}[color-inside]
\Block[tikz = {top color=blue, bottom color=white}]{*-*}{}
Mathilde \\
Pierre \\
Paul \\
Amélie \\
Jacques \\
Antoine \\
Stéphanie \\
\end{NiceTabular}

\end{document}

Output of the second code

In both cases, the instructions automatically take into account the number of row and columns of the tabular.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .