# Split nodes in TikZ math nodes matrix with Beamer?

TikZ matrices and Beamer do not work smooth -- for example, we have to use ampersand replacement work around. Is there a similar work around that allow one to use \nodepart ? The MWE is this:

\documentclass{beamer}
\usepackage{tikz}
arrows,shapes.geometric,shapes.multipart,trees,calc, fit, decorations.pathmorphing}
\begin{document}
\begin{frame}
\begin{tizpicture}
\node [circle split, draw] {outside matrix \nodepart{lower}works!};
\end{tikzpicture}
\begin{tikzpicture}
\matrix [matrix of math nodes,ampersand replacement=\&, nodes={circle split,draw}]
{
8 \& 1 \& 6 \\
3 \& 5 \&  7\nodepart{lower}2 \\
4 \& 9 \& 2 \\
};
\end{tikzpicture}
\end{frame}
\end{document}

• If you use matrix of nodes it works. if you use matrix of math nodes, you need to stop the math mode $7$ \nodepart{lower} $2$ and this is not done by that. It just skips the inner two dollar signs that's why it doesn't work. – percusse Aug 23 '14 at 8:02
• @percusse Many thanks! I feel very stupid now. I will use just matrix of nodes. Please consider copying and pasting this as an answer. I am changing the title so it may be useful for others. – Sergio Parreiras Aug 23 '14 at 15:06

matrix of math nodes implements the following node structure
\node (<matrixname>-<row #>-<col#>) {$<contents>$};

Here <contents> is replaced with whatever is found as the matrix entry. When the \nodepart is used, it is still in math mode and it trips up the macro. The correct way should have been
\node (<matrixname>-<row #>-<col#>) {$<upper contents>$\nodepart{lower}$<lower contents>$};

However, surrounding the \nodepart{lower} with dollar signs would not work because they are placed in different boxes so unmatched dollar signs trips the macros again. I can't think of any quick fix now.