Why the following document does not compile correctly? I would like an output drawing n
consecutive semicircles. For n=4
an output like this:
Is there a way to fix my code?
\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\def \n{4}
\foreach \i in {0,...,\n}
{
\tkzDefPoint(2*\i/\n,0){t_\i}
\tkzDrawPoint(t_\i)
}
\foreach \i in {0,...,\n/2}
{
\tkzDrawArc(t_(2*\i+1),t_(2*\i+2))(t_(2*\i))
}
\end{tikzpicture}
\end{document}
Here is a manual solution without foreach
:
\begin{tikzpicture}
\tkzDefPoint(0,0){A0}
\tkzDefPoint(.25,0){B0}
\tkzDefPoint(.5,0){A1}
\tkzDefPoint(.75,0){B1}
\tkzDefPoint(1,0){A2}
\tkzDefPoint(1.25,0){B2}
\tkzDefPoint(1.5,0){A3}
\tkzDefPoint(1.75,0){B3}
\tkzDefPoint(2,0){A4}
\tkzDrawSegments(A0,A4)
\tkzDrawArc(B0,A1)(A0)
\tkzDrawArc(B1,A2)(A1)
\tkzDrawArc(B2,A3)(A2)
\tkzDrawArc(B3,A4)(A3)
\end{tikzpicture}
\usetkzobj{all}
. The second is about parameters for the arc, they are names of points (t_0
) and you use operations which are not converted into names.\usetkzobj{all}
. But even after adding it I get the same error. I guess there is a syntax error in my code.