I want to draw smaller circles tangent to each other and tangent to the larger circle, as in the figure.

enter image description here

But, my figure does not appear with I would like, with the small circles really tangent to the larger circle .





\draw[ultra thick, red!95] (0,0) circle [radius=2.9];
\draw[ultra thick, blue!90] (3.4,2) circle [radius=1];
\draw[ultra thick, yellow!90] (2,3.4) circle [radius=1];
\draw[ultra thick, green!90] (0,4) circle [radius=1];
\draw[ultra thick, cyan] (-2,3.4) circle [radius=1];
\draw[ultra thick, black] (-3.4,2) circle [radius=1];
\draw[ultra thick, green!90] (-4,0) circle [radius=1];
\draw[ultra thick, blue!90] (-3.4,-2) circle [radius=1];
\draw[ultra thick, cyan] (-2,-3.4) circle [radius=1];
\draw[ultra thick, blue!90] (0,-4) circle [radius=1];
\draw[ultra thick, yellow!95] (2,-3.4) circle [radius=1];
\draw[ultra thick, black] (3.4,-2) circle [radius=1];
\draw[ultra thick, green!90] (4,0) circle [radius=1];
\node at (2.2,2.2) {$\mathbf{S_{1}}$};
\node at (0.8,3)   {$\mathbf{S_{2}}$};
\node at (-0.8,3)  {$\mathbf{S_{3}}$};
\node at (-2.2,2.2){$\mathbf{S_{4}}$};
\node at (-3,0.8)  {$\mathbf{S_{5}}$};
\node at (-3,-0.8) {$\mathbf{S_{6}}$};
\node at (-2.2,-2.2){$\mathbf{S_{7}}$};
\node at (-0.8,-3){$\mathbf{S_{8}}$};
\node at (0.8,-3)   {$\mathbf{S_{9}}$};
\node at (2.2,-2.2) {$\mathbf{S_{10}}$};
\node at (3,-0.8) {$\mathbf{S_{11}}$};
\node at (3,0.8) {$\mathbf{S_{12}}$};



2 Answers 2


There is a constraint here. You cannot have an arbitrary big and small radius, as well as an arbitrary number of circles, and also have them all be tangent as you describe.

The code below ensures that they are tangent, and calculates the required radius of the small circle from the given radius of the big circle.






% define the colors beforehand so they're in an array and easy to use
\def\circlecolors{blue!90, yellow!90, green!90, cyan, black, green!90, blue!90, cyan, blue!90, yellow!95, black, green!90}

% I'm doing trigonometry here....
\pgfmathsetmacro\smallradius{\bigradius * \s / (1-\s)}%

\draw[ultra thick, red!95] (0,0) circle [radius=\bigradius];

% Do the circles & labels in a loop, instead of one-by-one.
\foreach\circcolor [count=\i,
        evaluate={\i as \angle using {(3-\i)*360/\numcircles}}] in \circlecolors {
    % this "evaluate" statement gives us the angle. The "(3-\i)" 
    % is to shift the starting position of the labels to match the ones in
    % your picture. The negative is to ensure it goes counter-clockwise.

    % first draw the circle ....
    \draw[ultra thick,color=\circcolor] (\angle:{\smallradius+\bigradius}) circle [radius={\smallradius}];

    % and then add the label at an offset equal to half the angle
    \node  at ({\angle+180/\numcircles}:{\bigradius+0.2}){$S_{\i}$};


This results in the following figure:

resulting image

The lines overlap, but this can be eliminated by reducing the quantity \smallradius by the line width.

Regarding the trigonometry, simply draw two small circles tangent to the big circle, and one another; connect their centers with line segments. Let "r" be the bigger radius, "a" be the angle between the centers of the smaller circles, and and "x" be the smaller radius. It should be immediate that sin(a / 2) = x / (x+r), and I've just solved for x.


Something like this? Maybe you need some calculation to exclude line width from radius. Then it becomes a math problem that is not difficult to solve.

Following pic allows you to draw a big circle and arbitrary small cirles that have the same radius and line width and surround the big circle one by one.


  • r: radius of big circle
  • num: number of the small circles
  • small width: line width of small circle
  • big width: line width of big circle
  • pos: distance from the border of the big circle to node
  • color 0: color of big circle
  • color i (i >= 1): color of i th small circle

First small circle lies on 0 deg. If you have n small circles, then the second lies on 360/n deg and so on.

First node lies between the first and the second small circles, named picname-1 and so on.

enter image description here

\documentclass[tikz, border=1cm]{standalone}
\NewDocumentCommand {\myfor} { m +m } {
  \int_step_variable:nNn {#1} \l_for_tl {\def\forvar{\tl_use:N \l_for_tl}#2}

% predefine
  \pgfkeys{/multicircles/color \forvar/.initial=black}

    \pgfkeys{/pgf/fpu, /pgf/fpu/output format=fixed}
    \draw [\mc@color@main, line width=\mc@big@width] (0, 0) circle (\mc@R);
    \foreach \i in {1,...,\mc@num} {
      \def\temp@color{\pgfkeysvalueof{/multicircles/color \i}}
      \draw [\temp@color, line width=\mc@small@width] ({(\i-1)*\mc@ang}:\mc@rR) circle (\mc@r);
      \coordinate (-\i) at ({(\i-0.5)*\mc@ang}:\mc@node);
  /multicircles/.search also=/tikz,
  color 0/.store in=\mc@color@main,
  color 0=black,
  num/.store in=\mc@num, num=6,
  r/.store in=\mc@radius, r=1cm,
  big width/.store in=\mc@big@width,
  big width=1.6pt,
  small width/.store in=\mc@small@width,
  small width=1.6pt,
  pos/.store in=\mc@pos, pos=.3,
  \pic [pic type=mc, /multicircles/.cd,#1];
  colors/.code args={#1!#2!#3}{
        \noexpand\multicirclesset{color \forvar=#1!\pgfmathresult!#3}

    r=2cm, num=6, color 0=red!60,
    big width=3pt, small width=3pt,
    at={(0, 0)},
  \foreach \i in {1,...,6} {
    \node [font=\small] at (a-\i) {$S_{\i}$};
    r=3cm, num=12, color 0=red!60,
    big width=2pt, small width=4pt,
    at={(12, 0)},
  \foreach \i in {1,...,12} {
    \node [font=\tiny] at (b-\i) {$S_{\i}$};
    r=4cm, num=19, color 0=red!60,
    big width=8pt, small width=5pt,
    at={(24, 0)},
  \foreach \i in {1,...,19} {
    \node at (c-\i) {$S_{\i}$};

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.