4

enter image description hereI have drawn the below given figure using tikzpicture. In this figure, I want to draw the curly brace in shape of a circular arc (bent) along the circle from -45° to 90°. This is needed to label the diagram. On stack exchange I found only one close solution but it requires a lot of environments and commands to design/include (which are very hard to understand). I am looking for a simple solution to the problem. Many solutions have been tried, but I am only able to get is a straight brace as shown in the figure. So, help is required.

\documentclass[12pt]{book}
\hoffset-7mm

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{subcaption} 
\usetikzlibrary{positioning}
\usetikzlibrary{calc}

\begin{document}

\begin{figure}%a
    \centering      
    \begin{tikzpicture}[scale=1.5,
    %rotate=22.5,
    mynode/.style={draw, fill=white, circle, thick, minimum size=16pt, inner sep=0pt},
    myline/.style={line width=1.5}
    ]

    %% Setting coordinates
    \foreach \n in {1,...,8}{
        \coordinate (P\n) at (\n*45:1);
    }
    \coordinate (P9) at ($.5*(P3)+.5*(P8)$);
    \coordinate (P10) at ($.5*(P4)+.5*(P7)$);

    %% Drawing the graph
    \draw[myline,blue!70] (P7) -- (P8) -- (P9);
    \draw[myline,red!70] (P3) -- (P4) -- (P10);
    \draw[myline,green!70!black] (P1) -- (P9) -- (P2);
    \draw[myline] (P5) -- (P10);
    \draw[myline] (P6) -- (P7);
    \draw[myline] (P2) -- (P3);

    %% Drawing the shapes
    \draw[dashed, very thick] (0,0) circle (1.55);
    %       \draw [decorate,decoration={brace,amplitude=2pt,mirror,raise=4pt}] (1,1) arc (0:180:1.5 and 1);
    \draw[decorate,decoration=brace](45:1.7) arc (-45:90:1.7);

    \draw[green!70!black, very thick] (45:1.25) arc (45:90:1.25) arc (90:190:.25)
    -- ($(P9)+(-170:.25)$) arc (-170:-55:.25)
    -- ($(P1)+(-55:.25)$) arc (-55:45:.25);

    \draw[red!70, very thick] (135:1.25) arc (135:180:1.25) arc (180:250:.25)
    -- ($(P10)+(250:.25)$) arc (250:380:.25)
    -- ($(P3)+(20:.25)$) arc (20:135:.25);

    \draw[blue!70, very thick] (-45:1.2) arc (-45:0:1.2) arc (0:70:.2)
    -- ($(P9)+(70:.2)$) arc (70:215:.2)
    -- ($(P7)+(215:.2)$) arc (215:315:.2);

    %% Drawing the node
    \foreach \n in {1,...,10}{
        \fill (P\n) circle (.1);% node[scale=.3,white]{\n};
    }

    %% Labeling the clusters

    \end{tikzpicture}       
    \caption{}\label{fig:GMR1}
\end{figure}
\end{document}

1 Answers1

3

I just employed an existing solution and it (more or less) immediately worked.

\documentclass[12pt]{book}

\usepackage{tikz}
%\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}

\makeatletter 

\tikzset{curlybrace/.style={rounded corners=2pt,line cap=round}}%  
\pgfkeys{% https://tex.stackexchange.com/a/45129/121799
/curlybrace/.cd,%
tip angle/.code     =  \def\cb@angle{#1},
/curlybrace/.unknown/.code ={\let\searchname=\pgfkeyscurrentname
                              \pgfkeysalso{\searchname/.try=#1,
                              /tikz/\searchname/.retry=#1}}}  
\def\curlybrace{\pgfutil@ifnextchar[{\curly@brace}{\curly@brace[]}}%

\def\curly@brace[#1]#2#3#4{% 
\pgfkeys{/curlybrace/.cd,
tip angle = 0.75}% 
\pgfqkeys{/curlybrace}{#1}% 
\ifnum 1>#4 \def\cbrd{0.05} \else \def\cbrd{0.075} \fi
\draw[/curlybrace/.cd,curlybrace,#1]  (#2:#4-\cbrd) -- (#2:#4) arc (#2:{(#2+#3)/2-\cb@angle}:#4) --({(#2+#3)/2}:#4+\cbrd) coordinate (curlybracetipn);
\draw[/curlybrace/.cd,curlybrace,#1] ({(#2+#3)/2}:#4+\cbrd) -- ({(#2+#3)/2+\cb@angle}:#4) arc ({(#2+#3)/2+\cb@angle} :#3:#4) --(#3:#4-\cbrd);
}
\makeatother

\begin{document}

\begin{figure}%a
    \centering      
    \begin{tikzpicture}[scale=1.5,
    %rotate=22.5,
    mynode/.style={draw, fill=white, circle, thick, minimum size=16pt, inner sep=0pt},
    myline/.style={line width=1.5}
    ]

    %% Setting coordinates
    \foreach \n in {1,...,8}{
        \coordinate (P\n) at (\n*45:1);
    }
    \coordinate (P9) at ($.5*(P3)+.5*(P8)$);
    \coordinate (P10) at ($.5*(P4)+.5*(P7)$);

    %% Drawing the graph
    \draw[myline,blue!70] (P7) -- (P8) -- (P9);
    \draw[myline,red!70] (P3) -- (P4) -- (P10);
    \draw[myline,green!70!black] (P1) -- (P9) -- (P2);
    \draw[myline] (P5) -- (P10);
    \draw[myline] (P6) -- (P7);
    \draw[myline] (P2) -- (P3);

    %% Drawing the shapes
    \draw[dashed, very thick] (0,0) circle (1.55);
    %       \draw [decorate,decoration={brace,amplitude=2pt,mirror,raise=4pt}] (1,1) arc (0:180:1.5 and 1);
    \curlybrace[tip angle=-2,thick]{90}{-45}{1.7}
    \draw[green!70!black, very thick] (45:1.25) arc (45:90:1.25) arc (90:190:.25)
    -- ($(P9)+(-170:.25)$) arc (-170:-55:.25)
    -- ($(P1)+(-55:.25)$) arc (-55:45:.25);

    \draw[red!70, very thick] (135:1.25) arc (135:180:1.25) arc (180:250:.25)
    -- ($(P10)+(250:.25)$) arc (250:380:.25)
    -- ($(P3)+(20:.25)$) arc (20:135:.25);

    \draw[blue!70, very thick] (-45:1.2) arc (-45:0:1.2) arc (0:70:.2)
    -- ($(P9)+(70:.2)$) arc (70:215:.2)
    -- ($(P7)+(215:.2)$) arc (215:315:.2);

    %% Drawing the node
    \foreach \n in {1,...,10}{
        \fill (P\n) circle (.1);% node[scale=.3,white]{\n};
    }

    %% Labeling the clusters

    \end{tikzpicture}       
    \caption{}\label{fig:GMR1}
\end{figure}
\end{document}

enter image description here

  • It doesn't look like a brace anymore :) To me it is a set of two connected "hooked" arcs. –  May 17 '19 at 12:23
  • @JouleV Well, the author of the \curlybrace macro and several users who upvoted it, me included, think otherwise. –  May 17 '19 at 12:25