4

I want to split a TikZ node into a left and a right part, just like circle split does in upper and lower part, e.g.

\node [circle split,draw] (x){$a$ \nodepart{lower} $b$}

Is there a vertical equivalent, e.g.

\node [circle split vertical,draw] (x){$a$ \nodepart{right} $b$}?


Here is an example of a node which is split horizontally, however I would like the split to be vertical:

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

\begin{tikzpicture}
\node [circle split,draw] (z){$a$ \nodepart{lower} $b$};
\end{tikzpicture}

\end{document}
user56059
  • 43
  • 1
  • 5

3 Answers3

5

split

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

\begin{tikzpicture}
\node [circle split,draw,rotate=90] (z){\rotatebox{-90}{$a$} \nodepart{lower} \rotatebox{-90}{$b$}};
\end{tikzpicture}

\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
4

This solution uses PGF 3.0.0 pic new feature, to define a new pic element named node vertically split which receives two parameters which are the contents of the left and right parts. It also defines names to the parts of the pic which allow to later add different kind of connections, as it is shown in the example.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\tikzset{
    pics/circle vertically split/.style 2 args = {
       code = {
         \node[inner sep=3pt,left] (-left) {#1};
         \node[inner sep=3pt,right] (-right) {#2};
         \path let
              \p1 = ($(-left.north west) - (-left.east)$),
              \p2 = ($(-right.west) - (-right.south east)$),
              \n1 = {max(veclen(\p1), veclen(\p2))*2}
           in node[minimum size=\n1, circle, draw] (-shape) at (0,0) {};
         \draw (-shape.north) -- (-shape.south);
       }
    }
}

\begin{document}
\begin{tikzpicture}

\draw (0,0)  pic (A) {circle vertically split={$a$}{$b$}}
      (2,2)  pic (B) {circle vertically split={Hello}{World}}
      (2,-1) pic (C) {circle vertically split={Hello}{$b$}};

\draw[->, blue]  (A-shape) -- (B-shape);
\draw[blue, dotted] (C-shape.north east) -- (B-shape.south east);
\draw[->, red]   (A-right) to[out=0,in=90] (C-right.north);

\end{tikzpicture}
\end{document}

Result:

Result

JLDiaz
  • 55,732
1

A PSTricks solution:

\documentclass{article}

\usepackage{pstricks}

\def\size{2 }

\begin{document}

\begin{pspicture}(-\size,-\size)(\size,\size)
  \pswedge{\size}{90}{270}
  \rput(!-\size 2 div 0){\Huge $a$}
  \pswedge{\size}{270}{90}
  \rput(!\size 2 div 0){\Huge $b$}
\end{pspicture}

\end{document}

output