2

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?

1
  • 1
    The relative placement is inherited by the nodes in the path picture. Try using anchor=center as a key for the four nodes in the path picture. Commented Dec 4, 2013 at 13:58

2 Answers 2

1

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}
1

Here's a non-tikz approach:

\documentclass{article}
\usepackage{graphicx}
\usepackage{stackengine}
\begin{document}
\stackinset{c}{}      {c}{ 2.3ex}{N}{%
\stackinset{c}{}      {c}{-2.3ex}{S}{%
\stackinset{c}{ 2.3ex}{c}{}      {E}{%
\stackinset{c}{-2.3ex}{c}{}      {W}{%
\scalebox{3.5}{$\bigotimes$}%
}}}}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .