# Give tikz matrix columns all the same width and the rows all the same height (of the largest cell)

\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.

-
While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving problem. –  Peter Grill Nov 23 '12 at 8:10
you can use text width=\widthof{your longest text}. –  Ignasi Nov 23 '12 at 9:01
@Ignasi That is known as hardcoding the value. Only slightly removed from saying text width=45em. –  JonSlaughter Nov 23 '12 at 10:08

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}

-
Thanks. One problem I seem to have is that the rows are bigger than they should. I'm including graphics in cells which may be the cause. –  JonSlaughter Nov 23 '12 at 12:37
@JonSlaughter: Have you tried setting inner sep=0pt to remove the padding? –  Jake Nov 23 '12 at 12:40
just did, used align=center, anchor=center, inner sep= 10pt to get looking proper. Thanks again. –  JonSlaughter Nov 23 '12 at 12:41
How can I add these files (using MiKTeX on windows)? –  soandos Nov 13 '13 at 17:41