[Tex/LaTex] Give tikz matrix columns all the same width and the rows all the same height (of the largest cell)

tikz-pgf

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[align=left, text ragged, transform shape]
  \matrix [matrix of math nodes, every node/.style={font=\ttfamily, scale = 1, inner sep = 10pt},
        column 1/.style={align=left},
        nodes={font=\ttfamily, draw, left, minimum height=3em},
        row 1/.style={nodes={align=center}},
        ]
  {
    AAAA & BBB & CCCCCC\\
    EE & F & GGG \\
    aaaaa & bbbbb & c\\
  };
\end{tikzpicture}
\end{document}

Each rectangular box around each cell is of different sizes because each cell has a different width and height. I would like the width of a cell to be the maximum width of the column(which is the width of the maximum cell in that column), similarly, for the height of a row. This way the rectangles are properly sized and centering the text works as expected.

I do not want to hardcode the sizes because I do not know beforehand what the will be and this might require tweaking to get it right… and would be a lot of work anyways.

Another example is from

Vertical align in tikz matrix

But in my case I would like the problem cell to actually expand the height of all other cells in the same row(so the 3rd row will have about 1.5(or whatever) the height of the other rows). Again, though, the values should be calculated automatically rather than trying to determine them by hand.

Best Answer

You can use the excellent matrixcells package that Andrew Stacey made available on launchpad:

\documentclass{article}
\usepackage{tikz, matrixcells}
\usetikzlibrary{matrix}
\begin{document}

\begin{tikzpicture}
  \matrix [
    matrix of nodes, 
    matrix grid,
    matrix border,
    nodes={font=\ttfamily}
]
  {
    AAAA & BBB & CCCCCC\\
    EE & F & GGG \\
    aaaaa & b & c\\
  };
\end{tikzpicture}
\end{document}