# Nice table with TikZ

I am trying to produce a simple (nice looking) table. The tabular environment is unable to introduce padding in cells so I have tried it with TikZ. However I can't manage to get the cells align correctly.

How can I, using a matrix of nodes (or anything else), get a 3x3 table with rounded corners and centered elements in each cell?

How do I make the following look regular?

\begin{tikzpicture}
\matrix (mat) [matrix of nodes, row sep=-\pgflinewidth, nodes={draw=black, minimum width=3cm, minimum height=1cm}]
{
\emph{I tried} & Something
& ...  \\
$X$ & $X_{X_{X_X}}$
& $f : x \to y \to z \to \tau \to \omega$ \\
$X$ & ${{X^X}^X}^X$
& $f : x \to y$ \\
};
\end{tikzpicture}

• Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. A MWE should compile and be as small as possible to demonstrate your problem. it's much easier to help you if we have full working code to start from. – Andrew Jul 9 '18 at 7:55
• I have seen some very nice examples of TikZ tables on TeX.SX but when I searched I could not find them again. Here is one example, which I wrote, but I think there are better. – Andrew Jul 9 '18 at 7:57
• The tabular environment is unable to introduce padding in cells. Do you really think so? The cellspace and makecell packages might be of interest to you. – Bernard Jul 9 '18 at 8:00

Like this?

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}
\matrix (mat) [matrix of nodes, row sep=-\pgflinewidth, draw, rounded corners, nodes={minimum width=3cm, minimum height=1cm}]
{
\emph{I tried} & Something
& ...  \\
$X$ & $X_{X_{X_X}}$
& $f : x \to y \to z \to \tau \to \omega$ \\
$X$ & ${{X^X}^X}^X$
& $f : x \to y$ \\
};
\end{tikzpicture}

\end{document}


or this?

\documentclass[tikz,border=2mm]{standalone}

\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
\matrix (mat) [matrix of nodes,
row sep=0pt,
column sep=0pt,
%draw,
rounded corners,
nodes={minimum width=3cm, minimum height=1cm, anchor=center}]
{
\emph{I tried} & Something
& ...  \\
$X$ & $X_{X_{X_X}}$
& $f : x \to y \to z \to \tau \to \omega$ \\
$X$ & ${{X^X}^X}^X$
& $f : x \to y$ \\
};

%%As not all nodes fit in minimum width|height
%%We need to manually draw the boxes
\foreach \i in {1,2,3}{
\foreach \j in {1,2,3}
\draw[rounded corners] (mat-2-\i.west|-mat-\j-\i.north) rectangle (mat-2-\i.east|-mat-\j-\i.south);
}
\end{tikzpicture}

\end{document}

• anchor=center! I had missed that. – Damien L Jul 10 '18 at 9:35
• @DamienL. Yes, when you use matrix of nodes, nodes are anchored by default to their .base and you must change it to .center. I had same problem long time ago: tex.stackexchange.com/q/78964/1952 – Ignasi Jul 10 '18 at 10:08