You can use the fit
library to fit an ellipse
node around some other nodes. The syntax is fit={(<node1>) (<node2>) ...}
. To randomly place some nodes, you can use xshift=rnd*<length>
and yshift=rnd*<length>
. The random numbers change every minute, so to keep your results reproducible, you should fix the random seed using pgfmathsetseed=<integer>
:
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{fit,shapes}
\begin{document}
\pgfmathsetseed{12}
\begin{tikzpicture}[
random position/.style={
xshift=rnd*0.5cm,
yshift=rnd*2cm
}
]
\node (a) [random position] {1};
\node (b) [random position] {5};
\node (c) [random position] {7};
\node (d) [random position] {11};
\node (e) [random position] {$\cdots$};
\node [draw,ellipse,fit={(a) (b) (c) (d) (e)}] {};
\end{tikzpicture}
\end{document}