沿圆弧的花括号

沿圆弧的花括号

在此处输入图片描述我使用 tikzpicture 绘制了下图。在此图中,我想沿着圆从 -45° 到 90° 绘制圆弧形状(弯曲)的花括号。这是为了标记图表。在 stack exchange 上,我只找到了一个接近的解决方案,但它需要大量的环境和命令来设计/包含(这很难理解)。我正在寻找一个简单的解决方案。尝试了许多解决方案,但我只能得到如图所示的直括号。所以,需要帮助。

\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

我刚刚雇用了一个现有的解决方案并且它(或多或少)立即就起作用了。

\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}

在此处输入图片描述

相关内容