TiKz 中的括号图片

TiKz 中的括号图片

下图中的花括号是不对称的:

\newcommand{\mydistance}{.7cm}
\newcommand{\mydistancee}{0.1cm}
\begin{tikzpicture}[decoration={brace,amplitude=7pt}]
\node(G)                                                {$G$};
\node(H1)   [below=\mydistance of G]                    {$H_1$};
\node(H2)   [below=\mydistance of H1]               {$H_2$};
\node(1)        [below=\mydistance of H2]               {$\left\{1\right\}$};

\node(Gb)   [right=\mydistancee of G]               {};
\node(H1b)  [right=\mydistancee of H1]              {};
\node(1b)   [right=\mydistancee of 1]               {};

\draw(G)--(H1) node[midway, left=0.1cm]{2};
\draw(H1)--(H2) node[midway, left=0.1cm]{4};
\draw(H2)--(1) node[midway, left=0.1cm]{3};

\draw[decorate] (Gb) -- (H1b) node[midway, right=0.3cm] {$C_2$};
\draw[decorate] (H1b) -- (1b) node[midway, right=0.3cm] {$A_4$};

\end{tikzpicture}

上面的花括号稍微向左倾斜。如何让它变直?

你好,谢谢你的帮助,Dominik

答案1

您可以使用正交标识符,如中所述如何将一个节点垂直对齐到一个节点,并与另一个节点水平对齐?

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\newcommand{\mydistance}{.7cm}
\newcommand{\mydistancee}{0.1cm}
\begin{document}
\begin{tikzpicture}[decoration={brace,amplitude=7pt}]
\node(G){$G$};
\begin{scope}[node distance=\mydistance]
\node(H1) [below=of G]  {$H_1$};
\node(H2) [below=of H1] {$H_2$};
\node(1)  [below=of H2] {$\left\{1\right\}$};
\end{scope}

\begin{scope}[node distance=\mydistancee]
\coordinate[right=of G]  (Gb)   ;
\coordinate[right=of H1] (H1b)  ;
\coordinate[right=of 1]  (1b)   ;
\end{scope}

\draw(G)--(H1)  node[midway, left=0.1cm]{2};
\draw(H1)--(H2) node[midway, left=0.1cm]{4};
\draw(H2)--(1)  node[midway, left=0.1cm]{3};

\draw[decorate] (Gb-|H1b) -- (H1b) node[midway, right=0.3cm] {$C_2$};
\draw[decorate] (H1b) -- (1b) node[midway, right=0.3cm] {$A_4$};

\end{tikzpicture}
\end{document}

enter image description here

相关内容