Search code examples
graphicslatextikz

Example need for for-loops with tikz package in TeX


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


Solution

  • 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