【LaTeX应用】tikzpicture绘制流程图,框架图,训练模板直接套用即可

效果图如上所示,下面是代码

\begin{tikzpicture}[auto,
	box/.style = {draw, minimum height=3.5cm, 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]},
	}
	]
	
	\node (n1)  [box, 
	label={[lbl] north west:Challenger ~~ $\mathcal{C}$},
	]
	{$\begin{aligned}\\
		(pk,sk) \overset{R}{\leftarrow} G()  \\
		x \overset{R}{\leftarrow} X \\
		y \gets F(pk,x) \\
		t=\left\{
		\begin{aligned}
		1, \quad F(pk,I(sk,\widehat{y}))=\widehat{y}\\
		0, \quad F(pk,I(sk,\widehat{y}))\neq \widehat{y}
		\end{aligned}
		\right.
		\end{aligned}$
	};
	
	\node (n3)  [box, 
	label={[lbl]north west:Adversary~~ $\mathcal{A}$},
	right=25mm of n1 -| n1.east
	]
	{
	$ \widehat{y} \in Y $
	};
	
	\node (n4) [below=5mm of n3]{$ \widehat{x}  $};
	
	\path[arrow1]	([yshift=5ex] n1.east) -- node{$pk,y$} ([yshift=5ex] n3.west);
	\path[arrow1] ([yshift=-2ex] n3.west) -- node[above]{$\widehat{y}$} ([yshift=-2ex] n1.east);
	\path[arrow1] ([yshift=-6ex] n1.east) -- node{$t$} ([yshift=-6ex] n3.west);
	\path[arrow1] (n3) -- (n4);
	\end{tikzpicture}

可能还需要添加一些其他的包

\usepackage{tikz}
\usetikzlibrary{chains,scopes,positioning,backgrounds,shapes,fit,shadows,calc,arrows.meta}
\RequirePackage{amsmath,mathrsfs,amsfonts,amssymb}

这个版本的效果可能比较好,当然相比其他版本的话,也有一些比较繁琐的地方,但是代码还是相对简单易读的。

猜你喜欢

转载自blog.csdn.net/m0_50984266/article/details/112254334
今日推荐