# tikz: How to draw nested ellipses which contain bent text?

I would like to draw nested ellipses, where each ellipse shows some text (Function 1'',...,''Function 4'' to visualize dependence of function calls). I'd like to have the text bent according to the corresponding ellipse. The following is a first trial (not sure if it's a good approach to get to this picture). When I compile it (TeXLive 2012 on Ubuntu 12.10), it hangs... what's wrong? Or rather: What's a good way to draw this picture?

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[american]{babel}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathmorphing, decorations.text}

\begin{document}

\begin{tikzpicture}[decoration=zigzag]
% ellipses
\filldraw[fill=gray!10, draw=gray!80] (0,0) ellipse (6.4cm and 3.2cm);
\filldraw[fill=gray!20, draw=gray!80] (0,0) ellipse (4.8cm and 2.4cm);
\filldraw[fill=gray!30, draw=gray!80,
postaction={decorate,
decoration={text along path, text={\texttt{Function
2}}}}] (0,0) ellipse (3.2cm and 1.6cm);% TODO:
% place the text on top of "Function 1"
\filldraw[fill=gray!40, draw=gray!80] (0,0) ellipse (1.6cm and 0.8cm) node
{\texttt{Function 1}};
\end{tikzpicture}
\end{document}

-
As far as I can tell, the \texttt around 'Function 2' causes LaTeX to hang. Just don't know why... If you remove it, the code will compile just fine. –  Count Zero Feb 2 '13 at 23:43
@CountZero The text along path arranges its text letter by letter. The \texttt macro groups the text and TikZ can’t split it right. You can use |\ttfamily| …. –  Qrrbrbirlbel Feb 2 '13 at 23:51

Extract from pgfmanual:

Within the decoration text along path, each character in the text is typeset in a separate \hbox. [...] It is possible to format the text using normal formatting commands, such as \it, \bf and \color, within customizable delimiters. Initially these delimiters are both |

So, in your text, use |\tt|... instead of \texttt{...}:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[american]{babel}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathmorphing, decorations.text}

\begin{document}

\begin{tikzpicture}[decoration=zigzag]
% ellipses
\filldraw[fill=gray!10, draw=gray!80] (0,0) ellipse (6.4cm and 3.2cm);
\filldraw[fill=gray!20, draw=gray!80] (0,0) ellipse (4.8cm and 2.4cm);
\filldraw[fill=gray!30, draw=gray!80,
postaction={decorate,
decoration={text along path,
text={|\tt|Function 2},
},
}] (0,0) ellipse (3.2cm and 1.6cm);% TODO:
% place the text on top of "Function 1"
\filldraw[fill=gray!40, draw=gray!80] (0,0) ellipse (1.6cm and 0.8cm) node
{\texttt{Function 1}};
\end{tikzpicture}
\end{document}

-
1 min faster than me... :) –  Count Zero Feb 2 '13 at 23:54
@CountZero As I struggle to write rapidly in English, I cheat: I copy the documentation. :) –  Paul Gaborit Feb 3 '13 at 0:02
Thanks a lot. There is a follow-up here: tex.stackexchange.com/questions/96551/… –  Marius Hofert Feb 3 '13 at 0:12