Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have drawn an ellipse:

\node (elli) [ellipse, minimum height=3cm,minimum width=2cm, draw] {};

I would like to write some elements in it as the figure below shows. The position of the elements do not need to be precise, but I want them to be inside the ellipse.

Does anyone know how to do it?

enter image description here

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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