It is very common for me to need to place braces in matrix environment in a controlled fashion which I find NiceTabular
environment suitable for such purpose.
One difficulty I encounter is that when tables are very large in size, it becomes harder to determine the position of each cell in the table. Is it possible to systematically highlight the cells numbers using the counters iRow
and jCol
as follows?
The following requirements are to be met
- The highlighting color and transparency should be controllable
- Highlighting should go exactly in the middle of each cell (even when
\Block
environment is used, cells of the\Block
should still be highlighted) - If possible, the highlighting should be done using a convenient key to be added in the options
My MWE
\documentclass[11pt, a4paper]{article}
\usepackage{nicematrix}
\usepackage{calc}
\newlength{\widthCell}
\newcommand{\phantombox}[2]{%
\setlength{\widthCell}{\widthof{{Cell \arabic{iRow},\arabic{jCol}}}}%
{#2}\llap{\parbox{\widthCell}{\centering\color{gray!25}#1}}%
}
\begin{document}
\begin{NiceTabular}[hvlines,rules/color=[gray]{0.89},rules/width=0.2pt]{*{3}c}
\phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}} & \phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}} & \phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}}
\\
\phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}} & \phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}} & \phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}}
\\
\phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}} & \phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}} & \phantombox{\arabic{iRow},\arabic{jCol}}{Cell \arabic{iRow},\arabic{jCol}}
\\
\CodeAfter
\SubMatrix{\{}{1-1}{3-1}{.}
\SubMatrix{.}{1-2}{2-2}{\}}
\end{NiceTabular}
\end{document}
Best Answer
As usual with
nicematrix
, you need several compilations.