在 Latex 中绘制花括号

在 Latex 中绘制花括号

如何在节点周围绘制花括号。就像我在图片中给出的那样。

在此处输入图片描述

\begin{center}
\begin{tikzpicture}[shorten <=1cm,shorten >=1cm,-latex, align=center, node distance=1cm and 10cm,on grid,auto]

    \node (Owner) {\underline{\textbf{Owner}}};
    \node (Client) [right=of Owner] {\underline{\textbf{User}}};

    \node (Owner1) [below=1.5cm of Owner] {};
    \node (Owner2) [below=of Owner1] {};

   \node (Client1) [below=1.5cm of Client] {};
   \node (Client2) [below=of Client1] {};

   \path[-latex] 
   (Client1)    edge    node [above]{(1) Request Services} (Owner1)
   (Owner2)     edge    node [above]{(2) Sends addr } (Client2);

\end{tikzpicture}
\end{center}

答案1

您可以使用 tikz 的装饰库:

在此处输入图片描述

代码:

\documentclass{standalone}    
\usepackage{tikz}
\usetikzlibrary{positioning, decorations.pathreplacing}    

\begin{document}    
\begin{tikzpicture}

    \begin{scope}[shorten <=1cm,shorten >=1cm,-latex, align=center, node distance=1cm and 10cm,on grid,auto]
    \node (Owner) {\underline{\textbf{Owner}}};
    \node (Client) [right=of Owner] {\underline{\textbf{User}}};

    \node (Owner1) [below=1.5cm of Owner] {};
    \node (Owner2) [below=of Owner1] {};

   \node (Client1) [below=1.5cm of Client] {};
   \node (Client2) [below=of Client1] {};

   \path[-latex] 
   (Client1)    edge    node [above]{(1) Request Services} (Owner1)
   (Owner2)     edge    node [above]{(2) Sends addr } (Client2);
    \end{scope}

    \draw [decorate, decoration={brace}] (Client.east |- Client1.north) -- (Client.east |- Client2.south) node [midway, anchor=west, align=left] {write\\something};

\end{tikzpicture}
\end{document}

答案2

你可以用这个画一个支架:

\usetikzlibrary{decorations.pathreplacing}
\begin{tikzpicture}
    \draw [thick, decorate, decoration={brace,amplitude=10pt, mirror}](0,0) -- (0,10) node[midway,right,xshift=7pt] {Some Text};
\end{tikzpicture}

我认为它可以满足你的需要。

相关内容