14

I wanto to draw it, but

enter image description here

So I can make a part, but still without much quality

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
\usepackage{verbatim}

\begin{document}
\pagestyle{empty}


\begin{center}
\def\firstcircle{(0,0) circle (1cm)}
\def\secondcircle{(2,0) circle (1cm)}
\def\thirdcircle{(1,1.7) circle (1cm)} \qquad
\def\firstcircle{(5,0) circle (1cm)}
\def\secondcircle{(7,0) circle (1cm)}
\def\thirdcircle{(6,1.7) circle (1cm)}

\begin{tikzpicture}
    \draw \firstcircle node[below] {$K$};
    \draw \secondcircle node [above] {$K$};
    \draw \thirdcircle node [below] {$K$};
    \end{tikzpicture} \qquad
\begin{tikzpicture}
    \draw \firstcircle node[below] {$C$};
    \draw \secondcircle node [above] {$C$};
    \draw \thirdcircle node [below] {$C$};

\end{tikzpicture}
 \end{center}  

\end{document}
  • If you remove the options to the node the labels will be centered. – Peter Grill Jan 7 '15 at 17:24
  • Excuse me, are not only the labels, but are not perfectly tangent circles and also I can't get perfection the third row of discs – benedito Jan 7 '15 at 17:33
  • 1
    Sorry, did not see that upon initial inspection. Usually better to explicitly specify exactly what the problems you are trying to address. But, had I not been in a hurry I might have noticed it -- luckily others were more observant that I was. – Peter Grill Jan 7 '15 at 20:10
8

Since all answers are using tikz, just for fun using the modest \textcircled:

MWE

\documentclass[12pt]{article}
\usepackage[letterspace=-125]{microtype}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\def\K{\textcircled{\scriptsize{\bfseries K}}}
\begin{document}
\scalebox{6}{\begin{minipage}[c]{2cm}
\lsstyle\sffamily\lineskip1.25pt
\lineskiplimit50pt %large enough ... 
\centering
\K\\\K\K\\\K\K\K\\\K\K\K\K\\\K\K\K\K\K
\end{minipage}}
\end{document}

A similar result can be obtained with the \Kr command of the harmony package:

\documentclass{article}
\usepackage{harmony}
\def\K{\Kr{K}}
\begin{document}
{\parindent0pt\bfseries\centering\obeylines 
\K
\K\K
\K\K\K
\K\K\K\K
\K\K\K\K\K
}
\end{document}
19

A little bit cleaner.

\documentclass{scrartcl}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
  \foreach \n in {1,2,3,4}
    \foreach \m in {1,...,\n}
      \node[circle,draw,minimum size=1cm] at ($(60:\m cm)+(-\n cm,0)$) {K};
\end{tikzpicture}

\end{document}
17

Is something like this what you want?

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\draw[red] (0,0)--(3,0);
\draw[red] (0,0)--(60:3cm);
\draw[red] (3,0)--++(120:3cm);

\node[circle,draw,minimum size=1cm](a-1) {K};
\node[circle,draw,minimum size=1cm](b-1) at (60:1cm) {K};
\node[circle,draw,minimum size=1cm](c-1) at (60:2cm) {K};
\node[circle,draw,minimum size=1cm](d-1) at (60:3cm) {K};

\node[circle,draw,minimum size=1cm,right=0mm of a-1](a-2){K};
\node[circle,draw,minimum size=1cm,right=0mm of a-2](a-3){K};
\node[circle,draw,minimum size=1cm,right=0mm of a-3](a-4){K};

\node[circle,draw,minimum size=1cm,right=0mm of b-1](b-2){K};
\node[circle,draw,minimum size=1cm,right=0mm of b-2](b-3){K};

\node[circle,draw,minimum size=1cm,right=0mm of c-1](c-2){K};

\end{tikzpicture}
\end{document}

enter image description here

16

Stacking tikz balls.

\documentclass{article}
\usepackage[margin=15pt]{geometry}
\usepackage[usestackEOL]{stackengine}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
%\usepackage{verbatim}

\begin{document}
\pagestyle{empty}
\savestack{\K}{%
  \begin{tikzpicture}
    \draw (0,0) circle (1cm) node {\Huge\sffamily\bfseries K};
  \end{tikzpicture}}
\savestack{\C}{%
  \begin{tikzpicture}
    \draw (0,0) circle (1cm) node {\Huge\sffamily\bfseries C};
  \end{tikzpicture}}

\begin{center}
\setstackgap{L}{1.732cm}% =2cm * sin(60)
\Longstack{\K \\ \K\K \\ \K\K\K  \\ \K\K\K\K}
\qquad
\Longstack{\C \\ \C\C \\ \C\C\C  \\ \C\C\C\C}
\end{center}  
\end{document}

enter image description here


...and just to show some added stacking flexibility:

\documentclass{article}
\usepackage[margin=15pt]{geometry}
\usepackage[usestackEOL]{stackengine}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}
%\usepackage{verbatim}
\begin{document}
\pagestyle{empty}
\savestack{\K}{%
  \begin{tikzpicture}
    \draw (0,0) circle (1cm) node {\Huge\sffamily\bfseries K};
  \end{tikzpicture}}
\savestack{\C}{%
  \begin{tikzpicture}
    \draw (0,0) circle (1cm) node {\Huge\sffamily\bfseries C};
  \end{tikzpicture}}

\begin{center}
\setstackgap{L}{1.732cm}% =2cm * sin(60)
\Longstack{\K \\ \K\K \\ \K\K\K  \\ \K\K\K\K}
\qquad
\Longstack{\C \\ \C\C \\ \C\C\C  \\ \C\C\C\C}

\bigskip
\setstackgap{L}{2cm}% =2cm * sin(90)
\Longstack[l]{\K \\ \C\C \\ \K\K\K  \\ \C\C\C\C}
\qquad
\Longstack[r]{\C \\ \K\K \\ \C\C\C  \\ \K\K\K\K}

\end{center}  
\end{document}

enter image description here

8

Another option, with more succinct code than some but less concise than Manuel's. This solution uses the chains library.

\documentclass[tikz, border=5pt, varwidth, multi]{standalone}
\usetikzlibrary{chains,scopes}
\begin{document}
  \begin{tikzpicture}
    [
      node distance=0mm,
      every on chain/.style={draw, circle, minimum width=10mm},
      font=\sffamily\bfseries
    ]
    {[start chain=main going {at=(\tikzchainprevious), shift=(-60:10mm)}]
      \foreach \i in {1,...,4}
          \node (k\i) [on chain] {K};
      \foreach \i in {2,3,4}
        {[start chain=ck\i going left]
          \chainin (k\i);
          \foreach \j in {2,...,\i}
            \node [on chain=going left] {K};
        }
    }
    {[start chain=other going {at=(\tikzchainprevious), shift=(-60:10mm)}, xshift=50mm]
      \foreach \i in {1,...,4}
          \node (c\i) [on chain] {C};
      \foreach \i in {2,3,4}
        {[start chain=cc\i going left]
          \chainin (c\i);
          \foreach \j in {2,...,\i}
            \node [on chain=going left] {C};
        }
    }
  \end{tikzpicture}
\end{document}

small change

Should you require many piles of coins, you might prefer to use a pic. The following code defines a pic which takes 3 arguments. The first specifies the contents of each coin e.g. C or K, the second the number of rows in the pyramid e.g. 4, and the third the minimum diameter of each coin e.g. 10mm.

A pile of coins can then be defined as

\pic [<options>] {coins={<content>}{<rows>}{<diameter>}};

<options> can be used, for example, to change the colour of the coins or to shift them left or right.

\documentclass[tikz, border=5pt, varwidth, multi]{standalone}
\usetikzlibrary{chains,scopes}
\begin{document}
  \tikzset{
    pics/coins/.style n args={3}{
      code={
        \begin{scope}
          [
            node distance=0mm,
            inner sep=0pt,
            every on chain/.style={draw, circle, minimum width=#3, pic actions},
            font=\sffamily\bfseries,
            start chain=main going {at=(\tikzchainprevious), shift=(-60:#3)},
            pic actions
          ]
          \foreach \i in {1,...,#2}
              \node (#1\i) [on chain] {#1};
          \foreach \i in {2,...,#2}
            {[start chain=c#1\i going left]
              \chainin (#1\i);
              \foreach \j in {2,...,\i}
                \node [on chain=going left] {#1};
            }
        \end{scope}
      },
    },
  }
  \begin{tikzpicture}
    \pic [inner color=gray!25, outer color=gray!50, draw=gray, text=black] {coins={K}{4}{10mm}};
    \pic [green] at (50mm,0) {coins={C}{8}{5mm}};
    \pic [yshift=-50mm, xshift=25mm, inner color=yellow!50!orange!25, outer color=yellow!50!orange!50, draw=yellow!25!orange!50!black, text=yellow!25!orange!50!black] {coins={1p}{5}{15mm}};
  \end{tikzpicture}
\end{document}

riches

  • 1
    Dear CFR, when I compiled appear the message: line 31,32,33 : undefined control sequence \pic – benedito Jan 8 '15 at 9:55
  • 1
    @benedito You need TikZ/PGF version 3 for this to work. You must have an older version. – cfr Jan 8 '15 at 14:56

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.