0

This shouldn't be difficult, but I cannot make it work. I expected this code to generate the plot a certain sequence of blue points on a black circle:

\begin{tikzpicture}[scale=3]
\def\n{7}
\def\anglerot{222.5}
\draw(0,0) circle (1);
\foreach \i \in {0,...,\n} 
    \fill[color=blue] (cos (\i*\anglerot), sin (\i*\anglerot)) circle (.02);
\end{tikzpicture}

How can I fix it?

3

Use in instead of \in.

Version 1: \pgfmathsetmacro

\documentclass{article}
\usepackage{tikz}


\begin{document}

\begin{tikzpicture}[scale=3]
\pgfmathsetmacro\n{7}
\pgfmathsetmacro\anglerot{222.5}
\draw(0,0) circle (1);
\foreach \i in {0,...,7}  {
        \pgfmathsetmacro\x{cos (\i*\anglerot)}
        \pgfmathsetmacro\y{sin (\i*\anglerot)}
    \fill[color=blue] (\x, \y) circle (.02);
}
\end{tikzpicture}

\end{document}

Version 2: braces

\documentclass{article}
\usepackage{tikz}


\begin{document}

\begin{tikzpicture}[scale=3]
\def\n{7}
\def\anglerot{222.5}
\draw(0,0) circle (1);
\foreach \i in {0,...,\n} {
    \fill[color=blue] ({cos (\i*\anglerot)}, {sin (\i*\anglerot)}) circle (.02);
}
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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