I am trying to create a red box that covers multiple rows and columns for highlighting sections of a table.
I have created a MWE using @Steven B. Slegetes answer to this question. The code is:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\usepackage{multirow}
%Create Red Boxes, Thanks Steven
\def\boxit#1{%
\smash{\color{red}\fboxrule=1pt\relax\fboxsep=2pt\relax%
\llap{\rlap{\fbox{\vphantom{0}\makebox[#1]{}}}~}}\ignorespaces
}
\begin{document}
\begin{table}[h]
\caption{Red Box Test}
\vspace{0.5em}
\centering
\begin{tabular}{cccc}
& A & B & C \\toprule
I & 1 & 2 & 3 \
\boxit{0.4in} J & 4 & 5 & 6 \
K & 7 & 8 & 9 \\bottomrule
\end{tabular}
\end{table}
Which creates the following table:
Question: How do I get this to cover the row that begins with K as well as the row with J? I figured it must have something to with the multirow package, hence my including it. I have tried playing around with it to no avail.





\omit, there is, in fact, a complete row after the\bottomrule. I have not found yet the solution to avoid the need of that\omitin all the situations... – F. Pantigny Oct 10 '20 at 09:32