-1

call for help: could someone provide me a basic example of using the for-loops of TeX using the tikz package?

In particular: make 10 circles with common center, each one is bigger by 1cm in radius than the former one. Then, every 30 degrees draw a radius of the biggest one.

Another example: RAM picture. Make a single square, repeat it 10 times shifting the square by its' width * iteration step in every iteration.

References to certain pages of both TeX and TikZ manuals are kindly welcome! I am not sure what to look exactly in the manuals without going every page through, hence just vasting time.

Thank you

jupiter_jazz
  • 333
  • 2
  • 8

1 Answers1

3

In the future, please limit your question to one specific problem. If you have more than one question, split them into separate posts!

In the following an example for your first problem.

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

  \foreach \r in {1,...,10}{
    \draw (0,0) circle (\r);
  }

  \foreach \phi in {0,30,...,360}{
    \draw (0,0) -- (\phi:10);
  }

\end{tikzpicture}   

\end{document}

enter image description here

  • Splitting the question into two different posts leads to "omg it is a duplicate, the author is a spammer!11" In fact, that was a one specific problem: using for-s and tikz together. Thank you for the complete answer! – jupiter_jazz Mar 17 '20 at 11:01
  • is there any way for saying "for (int i = 0; i < 100; i++)" instead of foreach? – jupiter_jazz Mar 17 '20 at 11:02
  • 1
    @Kirill Of course there is a way, tex is Turing complete after all. However if you want to use tikz, you should use the tikz syntax, if you don't want to use this syntax, don't use tikz – samcarter_is_at_topanswers.xyz Mar 17 '20 at 17:09