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}
  • What do you mean by "brace" in a "circular arc"? – user156344 May 17 '19 at 11:14
  • A curly brace bent along the circle boundary between -45° to 90°. So that I can put a common label to the green and blue portions. – Optimist Optimizer May 17 '19 at 11:15
  • How will it look like? I can't imagine such a weird brace. To me, brace must be similar to }, i.e. it is on a straight path. – user156344 May 17 '19 at 11:17
  • But I have seen many braces curved along the circle which are required to label sectors/portions of a circle. – Optimist Optimizer May 17 '19 at 11:20
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. – user156344 May 17 '19 at 12:23
  • @JouleV Well, the author of the \curlybrace macro and several users who upvoted it, me included, think otherwise. – user121799 May 17 '19 at 12:25

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.