虚线,实线,双向箭头,箭头粗细,等等,都是在画图过程中,会遇到的问题,下面用一个简单案例展示,如何设计箭头,线条等
\begin{tikzpicture}[auto,
box/.style = {draw, minimum height=8cm, minimum width=3cm, align=left, outer sep=0pt},
lbl/.style = {anchor=north west, outer sep=0mm},
arrow1/.style = {
draw = black, thick, -{Latex[length = 2mm, width = 1.5mm]},
},
arrow2/.style = {
draw = black, dashed, line width=2pt, {Latex[length = 2mm, width = 2.5mm]}-{Latex[length = 2mm, width = 2.5mm]},
},
arrow3/.style = {
draw = black, line width=2pt, {Latex[length = 2mm, width = 2.5mm]}-{Latex[length = 2mm, width = 2.5mm]},
},
arrow4/.style = {
draw = black, dashed, line width=1pt, -{Latex[length = 2mm, width = 2.5mm]},
} ]
\node (n1) [box,
label={[lbl] north west:Challenger ~~ $\mathcal{C}$}
] {$ \begin{aligned}\\
(vk,sk) \overset{R}{\leftarrow} G()
\end{aligned} $ };
\node (n3) [box,
label={[lbl]north west:Adversary~~ $\mathcal{A}$},
right=20mm of n1
]
{ };
\node (n5) [draw,below=-8mm of n1]{$ V(vk) $};
\node (n4) [below=5mm of n1]{true or false};
\path[arrow1] ([yshift=2ex] n1.east) -- node{$ vk $} ([yshift=2ex] n3.west);
\path[arrow2] ([yshift=-2ex] n1.east) -- ([yshift=-2ex] n3.west);
\path[arrow4] ([yshift=-10ex] n1.east) -- ([yshift=-10ex] n3.west);
\path[arrow1] ([yshift=-6ex] n3.west) -- ([yshift=-6ex] n1.east);
\path[arrow3] ([yshift=-14ex] n3.west) -- ([yshift=-14ex] n1.east);
\path[arrow1] (n5) -- (n4);
\end{tikzpicture}
在导言区添加几行代码
\usepackage{tikz}
\usetikzlibrary{chains,scopes,positioning,backgrounds,shapes,fit,shadows,calc,arrows.meta}
\RequirePackage{amsmath,mathrsfs,amsfonts,amssymb}
上面的代码能够实现图中所示的案例,关于线条的更多控制,补充下面一些内容,各个属性可以组合使用,如案例所示
- 线条粗细控制
- 线条颜色,透明度
- 线条样式
- 线条两端控制
- 折线控制