2

This question is akin to this one, The difference being that I want to place my nodes during a foreach loop.

MWE:

\documentclass[border=5pt,tikz]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \def\thet{20};
    \def\radius{3.7};
    \foreach \ii in {1,2,...,18}
    \draw ({(\ii-1)*\thet}:\radius) arc [start angle = {(\ii-1)*\thet}, end angle ={(\ii)*\thet}, radius = \radius] node[midway] {$\theta_{\ii}$};
\end{tikzpicture}
\end{document} 

Results in this:

theta should always be outside the circle I would like the thetas to always be placed outside the circle (next to the apex of the arc from which they came), but if i use a positioning keyword such as right or above it will switch all thetas in the same directions, which is not what I want.

2

How about setting the node anchor to angle in the middle + 180?

\documentclass[border=5pt,tikz]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \def\thet{20};
    \def\radius{3.7};
    \foreach \ii in {1,2,...,18}
    \draw ({(\ii-1)*\thet}:\radius) arc [start angle = {(\ii-1)*\thet}, end
    angle ={(\ii)*\thet}, radius = \radius]
    node[midway,anchor={(\ii-1/2)*\thet+180}] {$\theta_{\ii}$};
\end{tikzpicture}
\end{document} 

enter image description here

  • Thanks ;-) This works abselultly great. Sadly I have no idea why , guess I'll need to read up on anchors (-; – Thorbjørn E. K. Christensen May 2 at 11:37
  • @ThorbjørnE.K.Christensen Some basics of anchors are explained on p. 233 of the pgfmanual, i.e. one can replace anchor=south by anchor=-90 and so on, and then other numbers are just a generalization thereof. – marmot May 2 at 11:43
  • 1
    Yup, I see now. It was even written on p. 228: "Unfortunately, while perfectly logical, it is often rather counter-intuitive that in order to place a node above a given point, you need to specify the south anchor" So it makes sense now ;-) Thanks a lot for the help. – Thorbjørn E. K. Christensen May 2 at 11:50

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.