5

I want to put circles along path, but they are not equidistant. The problem is that code is repetitive and ugly. Is there any other more elegant way to do that?

MWE:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}
\draw[decoration={markings,%
  mark=at position 0.1 with {\fill (0,0) circle (0.06);},%
  mark=at position 0.35 with {\fill (0,0) circle (0.06);},%
  mark=at position 0.5 with {\fill (0,0) circle (0.06);},%
  mark=at position 0.7 with {\fill (0,0) circle (0.06);},%
  mark=at position 0.85 with {\fill (0,0) circle (0.06);}},%
  postaction={decorate}] (0,0) arc (-35:-30:15) arc (-30:35:2) arc (215:170:1.5) arc (170:165:15);
\end{tikzpicture}

\end{document}

enter image description here

  • That is why it exists the option between positions x and y step z: see How to make a figure with moving arrows? – Claudio Fiandrino Mar 19 '15 at 8:41
  • 2
    @ClaudioFiandrino I think between positions x and y step z produces equidistant decorations. – Ignasi Mar 19 '15 at 9:25
  • @Ignasi: right.. my comment comes after having read the first sentence, where it seemed to me that the OP exactly wanted equidistant circles – Claudio Fiandrino Mar 19 '15 at 9:32
9

Use a /.list instead with a custom style that uses markings a few times. Otherwise you have to hack a macro that is not so fun.

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\pgfkeys{
  /pgf/decoration/irregular markings/.style = {
    mark= at position#1with {\fill (0,0) circle (0.06);}
  }
}

\begin{document}
\begin{tikzpicture}
\draw[decoration={markings,irregular markings/.list={0.1,0.35,0.5,0.7,0.85}},
      postaction={decorate}
] (0,0) arc (-35:-30:15) arc (-30:35:2) arc (215:170:1.5) arc (170:165:15);
\end{tikzpicture}
\end{document}

enter image description here

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.