How could I design a macro (if possible using \NewDocumentCommand) to add in a tikz matrix (created via tikzcd) something like |[stylename]| content? For now I can do:
\newcommand\zxZ[1]{|[Z]| #1}
but with NewDocumentCommand, this fails:
\NewDocumentCommand{\zxZ}{m}{|[Z]| #1}
Here is what I get for now:
MWE:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{cd}
\usetikzlibrary{backgrounds,positioning}
\usetikzlibrary{shapes,shapes.geometric,shapes.misc}
\usepackage{xparse}
\begin{document}
\tikzstyle{Z}=[fill=green]
% Works
%\newcommand\zxZ[1]{|[Z]| #1}
% Works (but I'd prefer the above |[Z]| since it seems to handle \arr and https://tex.stackexchange.com/a/21167/116348 better)
%\newcommand\zxZ[1]{\node[Z]{#1};}
% Fails
%\NewDocumentCommand{\zxZ}{m}{\node[Z]{#1};}
% Fails
%\NewDocumentCommand{\zxZ}{m}{|[Z]| #1}
\begin{tikzcd}
\node[Z]{\alpha}; & \zxZ{\beta}
\end{tikzcd}
\end{document}

\tikzsetwith\tikzstyleas per the author of the package: Should \tikzset or \tikzstyle be used to define TikZ styles?. – Peter Grill Oct 05 '21 at 15:52