Why does cellcolor not work here?
The code is from answer of my previous question here. I'm trying to color a cell of a table as the code here.
\documentclass[journal]{IEEEtran}
\usepackage{mathtools}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[!t]
\centering
\caption{Adjacency Matrix}
\label{tab:Adjacency Matrix}
\begin{tblr}{
colspec={*6{c}},
vline{1} = {2-Z}{0.8pt},
vline{2,Z} = {0.8pt},
vline{3-Y} = {0.3pt},
hline{1} = {2-Z}{0.8pt},
hline{2,Z} = {0.8pt},
hline{3-Y} = {0.3pt},
row{1} = {mode=math},
column{1} = {mode=math},
}
& V_1 & V_2 & V_3 & V_4 & V_5 \
V_1 & \cellcolor{gray!25}1 & 1 & 0 & 0 & 1 \
V_2 & 1 & 0 & 1 & 0 & 1 \
V_3 & 0 & 1 & 0 & 1 & 0 \
V_4 & 0 & 0 & 1 & 0 & 1 \
V_5 & 1 & 1 & 0 & 1 & 0 \
\end{tblr}
\end{table}
\end{document}

tabularayprovides two ways to colourise cells: either in a table definition viacell{rowA-rowB}{colX-colY}or directly in the "data" via\SetCell{...}as @Zarko answered. If it's just one cell, it doesn't matter. But if you have a range of cells to colourise, I'd use the former way. You can change both foreground and background of cells. Try to add the following to the table definition:cell{1}{2-Z} = {bg=blue,fg=white}, cell{2-Z}{1} = {bg=black!50!green,fg=white},. – Celdor Aug 18 '22 at 18:11