I'm trying to package a tikz key math array that lets me wrap the contents of a node inside an array environment in math mode, but I'm getting errors that I'm unable to debug.
Here's the code:
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{array}
\tikzset{
math array/.style={
execute at begin node=\(\begin{array}{#1},
execute at end node=\end{array}\)
},
}
\begin{document}
\begin{tikzpicture}
\node {
\(\begin{array}{c}
x\\
y
\end{array}\)
};
% this does not work
% \node[math array=c] {
% x\\
% y
% };
\end{tikzpicture}
\end{document}
The math array key is trying to reproduce what is written explicitly in the first node, but when used (in the commented part) I get strange errors about missing braces.
! Missing } inserted.
<inserted text>
}
l.27 y
What am I doing wrong? Is there an explanation of why is this happening?
EDIT: I've changed the example to have only a single column, to show that the problem does not lie in the & symbol.
@{}r@{}>{{{{}}l@{}is better thanrl? – AndréC Jul 24 '19 at 16:45@{}mean? – AndréC Jul 24 '19 at 17:51&. – egreg Jul 24 '19 at 21:05&symbol is not the issue – Nicola Gigante Jul 25 '19 at 07:26