There is a very nice TikZ code to visualize the cantor set such as
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
\pgfdeclarelindenmayersystem{cantor set}{
\rule{F -> FfF}
\rule{f -> fff}
}
\begin{document}
\begin{tikzpicture}
\foreach \order in {0,...,4}
\draw[yshift=-\order*10pt] l-system[l-system={cantor set, axiom=F, order=\order, step=100pt/(3^\order)}];
\end{tikzpicture}
\end{document}
from https://tex.stackexchange.com/a/386251/128042
I am wondering if there is an easy way to add annotations to each line. E.g., write $A_{\order}$ next to each line. I.e., write $A_0$ in front of the 1st line, $A_1$ in front of the 2nd line, and so on.


\foreachcommand. – Jasper Habicht Mar 07 '24 at 16:52