1

I've defined a node style which contains a path picture consisting into an inner node:

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

This style can be used inside a node:

\node[cross] {}; 

and can be used inside a \matrix:

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

enter image description here

but it fails when used inside a 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!

Could you explain me what's wrong?

Note: I've read Nodes and matrix of nodes but I think it describes another kind of problem.

The complete code is:

\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}
  • It is nodes={cross}: In path picture it will apply it again. So it causes infinite recursion of nodes. better add no cross or anything that can clean up nodes in path picture – Symbol 1 Mar 22 '17 at 21:41
  • @Symbol1 Thank you, I've never had thought about a recursion problem. – Ignasi Mar 23 '17 at 8:01
1
path picture={\node[every node/.style=,cross out, draw, ultra thick, red, minimum size=5mm] {};}},

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.