[Tex/LaTex] Parametrized circle node with a cross symbol

nodessymbolstikz-pgf

I am trying to get that result:

enter image description here

with a parametrized node that has 4 args for the 4 circle sections. I managed to achieve the following code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}

\tikzset{add/.style n args={4}{
    draw,
    circle,
    minimum width=6mm,
    path picture={
        \draw
            (path picture bounding box.south east) -- (path picture bounding box.north west)
            (path picture bounding box.south west) -- (path picture bounding box.north east);
        \node at ($(path picture bounding box.center)+(0,0.17)$)        {\tiny #1};
        \node at ($(path picture bounding box.center)+(0.17,0)$)        {\tiny #2};
        \node at ($(path picture bounding box.center)+(0,-0.17)$)       {\tiny #3};
        \node at ($(path picture bounding box.center)+(-0.17,0)$)       {\tiny #4};
        }
    }
}

\begin{document}

\begin{tikzpicture}[node distance=0.4cm]
    \node[add={1}{2}{3}{4}] (add1)  {}; 
    \node[add={1}{2}{3}{4},above=of add1]   (add2)  {}; 
    \begin{scope}[xshift=1cm,color=red]
        \node[add={1}{2}{3}{4}] (add3)  {}; 
        \node[add={1}{2}{3}{4}]  at (0,1) (add4)    {}; 
    \end{scope}
\end{tikzpicture}

\end{document}

which outputs:

enter image description here

As can be seen, there is a problem when a node is positioned relatively to another. Any idea of how to fix this?

Best Answer

The solution was to add anchor=center in the /.style.

Thanks Mark!

    \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}


\tikzset{add/.style n args={4}{
    draw,
    circle,
    minimum width=6mm,
    path picture={
        \draw
            (path picture bounding box.south east) -- (path picture bounding box.north west)
            (path picture bounding box.south west) -- (path picture bounding box.north east);
        \node[anchor=center] at ($(path picture bounding box.center)+(0,0.17)$)     {\tiny #1};
        \node[anchor=center] at ($(path picture bounding box.center)+(0.17,0)$)     {\tiny #2};
        \node[anchor=center] at ($(path picture bounding box.center)+(0,-0.17)$)    {\tiny #3};
        \node[anchor=center] at ($(path picture bounding box.center)+(-0.17,0)$)    {\tiny #4};
        }
    }
}

\begin{document}

\begin{tikzpicture}[node distance=1cm]
    \node[add={1}{2}{3}{4}] (add1)  {}; 
    \node[add={1}{2}{3}{4},above=of add1]   (add2)  {}; 
    \begin{scope}[xshift=1cm,color=red]
        \node[add={1}{2}{3}{4}] (add3)  {}; 
        \node[add={1}{2}{3}{4}]  at (0,1.3) (add4)  {}; 
    \end{scope}
\end{tikzpicture}

\end{document}