I've adapted the example below from elsewhere on this forum. What I'd like is to have the background fill to come out as a rectangle covering the contents of all cells. What is the easiest way to accomplish that automatically in tikz, i.e. in such a way that the code works regardless of the cell contents? (I know how to fudge things manually using minimum width
, \vphantom
and the like, but I'm looking for something automatic in tikz.)
Thanks!
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,positioning}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)
{
8 &8 & \dfrac{1}{5} &6 \\
\text{three} &\dfrac{8}{3} &5 &7 \\
4 &8 &9 &5 \\
};
\draw[fill=pink,opacity=0.2] (m-1-1.north west) -- (m-1-3.north east) -- (m-2-3.south east) -- (m-2-1.south west) -- (m-1-1.north west);
\end{tikzpicture}
\end{document}
Best Answer
Instead to draw line arround nodes try to use rectangle shape, which fit this nodes: