# How to get a ellipse shaped node in Tikz Network?

I am using the excellent tikz-network package written by Jürgen Hackl. I am trying to change shape of some nodes to be an ellipse, but I can't figure out how to. From the manual, tikz-network:

With the option shape the shape of the vertex can be modified. Thereby the shapes implemented in TikZ can be used, including: circle, rectangle, diamond, trapezium, semicircle, isosceles triangle, ...

But when I compile this code:

\documentclass{article}
\usepackage{tikz-network}
\begin{document}

\begin{tikzpicture}
\Vertex[color=white, x=-1, y=1, label=A]{A}
\Vertex[color=white, x=1, y=1, label=B, shape=rectangle]{B}
\Vertex[color=white, x=0, y=0, label=2, shape=ellipse]{2}
\Edge[lw=1, Direct](A)(2)
\Edge[lw=1, Direct](B)(2)
\end{tikzpicture}

\end{document}


all I get is this

while I would expect the shape of node 2 to be an ellipse, not a circle.

• Try use 2222222 instead of 2 – user156344 May 9 at 16:53
• Thank you JouleV. I actually tried this already, down the the number of 2s! ;) but the label just spills over. – Leo May 9 at 17:03

Actually, your shape is an ellipse. It just happens to be the same height and width, because those are the default settings. You can give extra TikZ options using the style option of \Vertex.

\documentclass{article}
\usepackage{tikz-network}
\begin{document}

\begin{tikzpicture}
\Vertex[color=white, x=-1, y=1, label=A]{A}
\Vertex[color=white, x=1, y=1, label=B, shape=rectangle]{B}
\Vertex[color=white, x=0, y=0, label=2, shape=ellipse, style={minimum width=2cm}]{2}
\Edge[lw=1, Direct](A)(2)
\Edge[lw=1, Direct](B)(2)
\end{tikzpicture}

\end{document}


• Thanks to your answer I also figured out how to use the regular polygon shape for a vertex: "\Vertex[color=white, x=-1, y=1 shape=regular polygon, style={regular polygon sides=5}, label=A]{A}" – Leo May 9 at 17:20

Let me start by spelling out your and and Joule V's observation that the text will just overshoot if is longer than the package expects it to be.

\documentclass{article}
\usepackage{tikz-network}
\begin{document}

\begin{tikzpicture}
\Vertex[color=white, x=-1, y=1, label=A]{A}
\Vertex[color=white, x=1, y=1, label=B, shape=rectangle]{B}
\Vertex[color=white, x=0, y=0, label=2222222, shape=ellipse]{2}
\Edge[lw=1, Direct](A)(2)
\Edge[lw=1, Direct](B)(2)
\end{tikzpicture}

\end{document}


Needless to say that this looks a bit suboptimal. The internal reason why that happens is that the text is not the node contents, as one may naively suspect/hope, but, as the label indicates, a label. This problem can be solved as follows:

\documentclass{article}
\usepackage{tikz-network}
\makeatletter
\tikzset{network x offset/.initial=1ex,network y offset/.initial=1ex,
minimum height=height("\vertex@Label")+2*\pgfkeysvalueof{/tikz/network y offset}}}
\makeatother
\begin{document}

\begin{tikzpicture}
\Vertex[color=white, x=-1, y=1, label=A]{A}
\Vertex[color=white, x=1, y=1, label=B, shape=rectangle]{B}
\tikzset{every label/.append style={}}
\Vertex[color=white, x=0, y=0, label=2222222, shape=ellipse,

So all you need to do is to add style={adjust size}. As a side effect, this will then really become an ellipse if, as suggested by JouleV, once you insert a wider (or higher) text. The keys network x offset and network y offset can be thought of as the analogues of the ordinary pgf keys inner xsep and inner ysep.