【LaTeX应用】画图,上面一个图形,下面两个图形,竖直方向居中

如图所示,在上面有一个矩形框,下面两个矩形框,如何让上面矩形框居中,下面矩形框也居中?

采用一种比较讨巧的方式实现:在上面矩形框的下面定义一个无内容的空矩形框,然后下面两个矩形框在这个空矩形框的基础上左右排列

\begin{tikzpicture}[auto,
	box/.style = {draw, minimum height=3cm, 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 (n0) [draw,minimum height=1cm, minimum width=3cm, label={[lbl] north west:KG ~~ $\mathcal{G}$},] {};
	\node (n00) [below =30mm of n0] {};
	
	\node (n1)  [box, 
	label={[lbl] north west:Prover ~~ $\mathcal{P}$},
	left = 10mm of n00
	]	{	};
	
	\node (n3)  [box, 
	label={[lbl]north west:Verifier~~ $\mathcal{V}$},	
	right=10mm of n00
	]
	{	};
	
	\node (n4) [below=5mm of n3]{true or false};
	
	\path[arrow1]	([yshift=2ex] n1.east) -- node{} ([yshift=2ex] n3.west);
	\path[arrow1] ([yshift=-2ex] n3.west) -- node[above]{} ([yshift=-2ex] n1.east);
	\path[arrow1] ([yshift=-6ex] n1.east) -- node{} ([yshift=-6ex] n3.west);
	\path[arrow1] (n3) -- (n4);
	\path[arrow1] (n0) --node{$ sk $} (n1.north);
	\path[arrow1] (n0) --node{$ vk $} (n3.north);
	\end{tikzpicture}

思考:如果是上面两个矩形框,下面一个矩形框,要求下面的矩形框也是居中对齐,应该如何设置呢?

猜你喜欢

转载自blog.csdn.net/m0_50984266/article/details/112547890