3

I'm having a hard time splitting a node circle in three parts.

I want to have the circle split horizontally and then the bottom part split in two vertically like in this picture:

split circle

I still want to be able to place text inside each parts.

thanks in advance

Edit I can end up with the circle like in the picture above but I can't place text in each part like I want.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\begin{document}

\begin{tikzpicture}[scale =3 ]
\node [circle split,draw,text width=15em] (z){$a$ \hfill $b$}; \draw 
(z.center) -- (z.south);
\end{tikzpicture}

\end{document}
4
  • Welcome to TeX.SX! It would be great if you could show us what you have tried to produce these images. Posting a minimal working example that indicates what you are trying to do makes it easier for people to understand what you want. It also makes it easier for people to help you, since they have some code to start from, and hence much more likely that some one will try to help you.
    – user30471
    Sep 29 '17 at 7:20
  • thanks for your answer, I've edited my post to add some code. Sep 29 '17 at 7:33
  • 1
    Possible duplicate: tex.stackexchange.com/a/59018
    – Ross
    Sep 29 '17 at 8:14
  • I didn't came across that post during my research but it's definitely the same question Sep 29 '17 at 8:50
2

To write in the different parts of a split node you use the \nodeparts command -- see section 17.3 of the pgf/tikz manual. In this case, you have artificially created three node parts out of a circle split so you access write in the top and bottom parts of the node using

\node[circle split, draw]{top text\nodepart{lower} lower text};

To write into the left and right components of the bottom split I think that you need to fudge. Here is one way of doing this:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\begin{document}

\begin{tikzpicture}[scale =3 ]
  \node [circle split,draw] (z){1\nodepart{lower} 2\quad 3};
  \draw (z.center) -- (z.south);
\end{tikzpicture}

\end{document}

This produces:

enter image description here

It ought to be possible to "properly" define this type of split node part, in which case you'd be able to write in each component without this hack.

Here is another way of doing this by defining a pic (see section 18.2 of the tikz manual), to create your node shape and then put the text in to each piece. The syntax for the pic is

pic{mysplit={radius, top text, left text, right text}

You can place pics using \pic commands or \draw(x,y)pic{...}. Doing it this way the MWE

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\begin{document}

\tikzset{
  pics/mysplit/.style args = {#1,#2,#3,#4}{% radius, top tex, left text, right text
    code = {
        \draw (0,0) circle (#1); % draw the circles and the lines
        \draw(-#1,0)--(#1,0);
        \draw(0,0)--(0,-#1);
        \pgfmathsetmacro\half{#1/3}% a third looked better than a half...
        \node at (0,\half){#2};
        \node at (-\half,-\half){#3};
        \node at (\half,-\half){#4};
    }
  }
}

\begin{tikzpicture}
    \draw (0,0) pic{mysplit={1,1,2,3}};
    \draw (4,0) pic{mysplit={1.5,One,Two,Three}};
\end{tikzpicture}
\end{document}

produces:

enter image description here

1
  • Exactly what I was looking for, thanks a lot for your answer. Sep 29 '17 at 8:47

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