是否可以用花括号将一组节点括起来,并在花括号的右下角附近放置一些文本。
\documentclass[a4paper]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{tikz}
\usepackage{tikz-uml}
\usetikzlibrary{shapes.multipart,positioning,fit}
\usepackage{pgf-umlsd}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\node[text width=3cm] (A) at (0,0) {\tiny AAA};
\node[anchor=north west , text width=1cm] (A1) at (A.south west) {\tiny BBB};
\node[anchor=west , text width=1cm] (A2) at (A1.east) {\tiny CCC};
\node[anchor=west , text width=1cm] (A3) at (A2.east) {\tiny DDD};
\node[anchor=north west , text width=1cm] (A4) at (A1.south west) {\tiny EEE};
\node[anchor=west , text width=1cm] (A5) at (A4.east) {\tiny FFF};
\node[anchor=west , text width=1cm] (A6) at (A5.east) {\tiny };
\node [inner sep=0pt,
draw,
rounded corners,
fit = (A)(A1)(A2)(A3)(A4)(A5)(A6)
] (A13) {};
\draw (A1.north west) -- (A3.north east)
(A1.south west) -- (A3.south east);
\end{tikzpicture}
\end{document}
答案1
\documentclass[a4paper]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{tikz}
%\usepackage{tikz-uml}
\usetikzlibrary{shapes.multipart,positioning,fit}
\usepackage{pgf-umlsd}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathreplacing} % <--- add this
\begin{document}
\begin{tikzpicture}
\node[text width=3cm] (A) at (0,0) {\tiny AAA};
\node[anchor=north west , text width=1cm] (A1) at (A.south west) {\tiny BBB};
\node[anchor=west , text width=1cm] (A2) at (A1.east) {\tiny CCC};
\node[anchor=west , text width=1cm] (A3) at (A2.east) {\tiny DDD};
\node[anchor=north west , text width=1cm] (A4) at (A1.south west) {\tiny EEE};
\node[anchor=west , text width=1cm] (A5) at (A4.east) {\tiny FFF};
\node[anchor=west , text width=1cm] (A6) at (A5.east) {\tiny };
\node [inner sep=0pt,
draw,
rounded corners,
fit = (A)(A1)(A2)(A3)(A4)(A5)(A6)
] (A13) {};
\draw (A1.north west) -- (A3.north east)
(A1.south west) -- (A3.south east);
\draw [red,thick,decorate,decoration={brace,amplitude=5pt,mirror,raise=1ex}]
(A13.north west) -- (A13.south west) ;
\draw [red,thick,decorate,decoration={brace,amplitude=5pt,raise=1ex}]
(A13.north east) -- (A13.south east) node[right,xshift=0.5em]{your text};
\end{tikzpicture}
\end{document}
答案2
您也可以只使用矩阵,它提供这些花括号作为分隔符,这可能是排列文本“AAA”、“BBB”等的更自然的方式。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,column sep=1.5em,draw,rounded corners=4pt,
left delimiter=\{,right delimiter=\}](m){
AAA & & \\
BBB & CCC & DDD\\
EEE & FFF & \\
};
\path (m-1-1) -- coordinate (aux1) (m-2-1) -- coordinate (aux2) (m-3-1)
foreach \x in {1,2}{(aux\x-|m.west) edge (aux\x-|m.east)};
\end{tikzpicture}
\end{document}