Suppose I have a 4 x 4 table that was created in the tabular environment. I want to outline the borders of the 3 x 3 sub-table that sits in the lower right corner in a color that is different from the lines that separate the cells in the other parts of the table. Is there a relatively easy way to do this?
Asked
Active
Viewed 247 times
0
Junglemath
- 144
-
2See also: Coloring a sub-table – leandriis Sep 06 '20 at 19:52
1 Answers
1
One way is as below with the fit library -- the horizontal and verticals have been removed for clarity -- you could set them back
\documentclass{article}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,fit}
\begin{document}
\begin{tabular}{cccc}
%\hline
1 & {3} & 2& B\
%\hline
A & \tikzmarknode{B1}B& {C}& B\
%\hline
D & E & K&{B} \
%\hline
G & H & I& \tikzmarknode{B2}B\
%\hline
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\node[ draw=blue,line width=2pt,fit={(B1)(B2)($(B1.north west)+(-2pt,-0pt)$)($(B2.south east)+(2pt,-0pt)$)}]{};
\end{tikzpicture}
\end{document}
js bibra
- 21,280
-
Nice, although I've never used tikz. I guess I'll have to learn it someday, and I'll keep this in mind. – Junglemath Sep 07 '20 at 02:11
