具有复杂节点的节点矩阵问题

具有复杂节点的节点矩阵问题

我定义了一个节点样式,其中包含path picture一个内部节点:

cross/.style={circle, minimum size=1cm,
    draw=black!70, fill=white,
    path picture={%
        \node[cross out, draw, ultra thick, red, minimum size=5mm]{};}}

这种风格可以在内部使用node

\node[cross] {}; 

并且可以在内部使用\matrix

\matrix[fill=black!20, xshift=2cm] (b) {%
     \node[cross]{}; & \node[cross]{};\\ 
     \node[cross]{}; & \node[cross]{};\\};

在此处输入图片描述

matrix of nodes但在with内部使用时会失败nodes=cross

! TeX capacity exceeded, sorry [grouping levels=255].
\pgfutil@g@addto@macro #1#2->\begingroup 
                                         \pgfutil@toks@ \expandafter {#1#2}\...
l.15 ...odes={cross}, nodes in empty cells] (c) {&
                                                   \\ & \\};
!  ==> Fatal error occurred, no output PDF file produced!

你能解释一下我哪里出了问题吗?

注:我已阅读节点和节点矩阵但我认为它描述了另一种问题。

完整代码如下:

\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{shapes.misc, positioning, matrix}

\begin{document}
\begin{tikzpicture}[
    cross/.style={circle, minimum size=1cm,
        draw=black!70, fill=white,
        path picture={\node[cross out, draw, ultra thick, red, minimum size=5mm] {};}},
    ]

    % This works
    \node[cross] (a) {};

    %This works
    \matrix[fill=black!20, xshift=2cm] (b) {\node[cross]{}; & \node[cross]{};\\ \node[cross]{}; & \node[cross]{};\\};

    %This is wrong
    %\matrix[fill=black!20, xshift=6cm, matrix of nodes, nodes={cross}, nodes in empty cells] (c) {& \\ & \\};
\end{tikzpicture}
\end{document}

答案1

path picture={\node[every node/.style=,cross out, draw, ultra thick, red, minimum size=5mm] {};}},

在此处输入图片描述

相关内容