In order to create nice alignments in a tikzcd-like environment (zx-calculus package), I'd like to find a simple way to change the bounding box of a node (without changing its content itself ideally, but in practice it will have opacity 0 anyway, and I may also be interested in scopes), notably to have zero-height or zero-width similar to how vphantom or hphantom can work. Is it possible to create a simple style that would apply this?
MWE:
\documentclass[]{article} \usepackage{tikz-cd} \NewExpandableDocumentCommand{\mynode}{O{}m}{\node[circle, inner sep=10pt,draw,fill=red,#1]{#2};} \begin{document} I'd like the bounding box of the semi-transparent Foo circle to have zero width (so its content will overlap with B and go outside of the fbox to the right, in practice it is not much of an issue as opacity will often be 0) but its actual height should be unchanged: \fbox{\begin{tikzcd}[ampersand replacement=\&,column sep=3mm] A \& \mynode{Foo} \\ \& B \& \mynode[opacity=.1]{Foo} \end{tikzcd}} \end{document} 

\NewExpandableDocumentCommandis out of place: it should be\NewDocumentCommand, because the replacement text is not fully expandable.\NewDocumentCommandthis wont compile, I think that tikzcd is testing if\nodeis the next text and if not it does something different… and using expandable fixes this. If you have a cleaner solution that lets me use xparse syntax I'd be happy to hear it though.