我计划绘制以下这样的图片:
到目前为止我已经尝试过这个:
\documentclass[12pt]{article}
\usepackage{multirow,graphics,graphicx,supertabular}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.pathreplacing,calc,positioning,calligraphy}
\begin{document}
\begin{tikzpicture}
\matrix (m)
{
\node {\textbf{Name}}; & \node{\textbf{Age}}; & \node {\textbf{Balance}}; \\ \hline
\node {User 1}; & \node{35}; & \node {7}; \\
\node {User 2}; & \node{42}; & \node {7}; \\
\node { }; & \node{ }; & \node { }; \\
\node {User 3}; & \node{42}; & \node {7}; \\
\node {User 4}; & \node{42}; & \node {7}; \\
};
\draw[decorate] (m-2-2.north east) -- node[right=2pt] {$m$} (m-2-4.south east); % right
\end{tikzpicture}
\end{document}
我如何才能实现这个期望的输出?箭头不完全应该是这样的。它们应该是干净、漂亮的箭头。
我还需要这个来绘制:
答案1
这个怎么样?
\documentclass[crop]{standalone}
\usepackage{multirow,graphics,graphicx,supertabular}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\matrix (m1) [matrix of nodes]
{
\textbf{Name} & \textbf{Age} & \textbf{Balance} \\ \hline
User 1 & 35 & 7 \\
User 2 & 42 & 7 \\
& & \\
User 3 & 42 & 7 \\
User 4 & 42 & 7 \\
};
\matrix [right=of m1] (m2) [matrix of nodes]
{
\textbf{Name} & \textbf{Age} \\ \hline
User 1 & 35 \\
User 2 & 42 \\
& \\
User 3 & 42 \\
User 4 & 42 \\
};
\draw[decorate,
decoration={
brace,
mirror,
amplitude=5pt,
raise = 1pt,
},
thick,
] (m1-2-1.west) -- (m1-6-1.west)
node [
pos=0.5,
left=5pt,
] { text };
\draw[decorate,
decoration={
brace,
mirror,
amplitude=5pt,
raise = 1pt,
},
thick,
] (m1-6-1.south west) -- (m1-6-3.south east)
node [
pos=0.5,
below=5pt,
] { text };
\draw[decorate,
decoration={
brace,
mirror,
amplitude=5pt,
raise = 1pt,
},
thick,
] (m2-6-1.south west) -- (m2-6-2.south east)
node [
pos=0.5,
below=5pt,
] { text };
\draw[decorate,
decoration={
brace,
amplitude=5pt,
raise = 1pt,
},
ultra thick,
] (m1-1-1.north west) -- (m2-1-2.north east)
node [
pos=0.5,
above=5pt,
] { text };
\end{tikzpicture}
\end{document}
答案2
同样带有matrix
库,但使用calligraphy
括号和所有图片元素样式定义作为tikzpicture
选项:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,
calligraphy,
matrix,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 7mm,
BC/.style args = {#1/#2}{decorate,
decoration={calligraphic brace, amplitude=2mm,
pre =moveto, pre length=1mm,
post=moveto, post length=1mm,
raise=#1},% for mirroring of brace
very thick,
pen colour=#2},
M/.style = {matrix of nodes,
nodes={minimum width=4em, minimum height=3ex},
row sep=0ex,
row 1/.append style = {nodes={font=\bfseries}},
},
N/.style = {font=\small, sloped}
]
\matrix (m1) [M]
{
Name & Age & Balance \\
\hline
User 1 & 35 & 7 \\
User 2 & 42 & 7 \\
User 3 & 42 & 7 \\
User 4 & 42 & 7 \\
};
\matrix[right=of m1] (m2) [M]
{
Name & Age \\
\hline
User 1 & 35 \\
User 2 & 42 \\
User 3 & 42 \\
User 4 & 42 \\
};
\draw[BC=1mm/red] (m1.north west) -- node[above=3mm] {text above} (m2.north east);
\draw[BC=1mm/red] (m1-5-1.south west) -- node[left =3mm] {text left} (m1-2-1.north west);
\draw[BC=1mm/red] (m1.south east) -- node[below=3mm] {text below} (m1.south west);
\draw[BC=1mm/red] (m2.south east) -- node[below=3mm] {text below} (m2.south west);
%
\draw[BC=1mm/red] (m2-2-2.north east) -- node[right=3mm] {text right} (m2-3-2.south east);
\draw[BC=1mm/red] (m2-4-2.north east) -- node[right=3mm] {text right} (m2-5-2.south east);
\end{tikzpicture}
\end{document}