我的幻灯片上有两张TikZ
图片,现在它们并排显示。我想让第一张图片位于另一张图片之上。另外,我想在 Alice 和 Bob 之间画三支箭头,但目前从 Alice 到 Bob 的箭头中的文本“0
或1
”位置不正确,我还想在箭头下方再画一支从 Bob 到 Alice 的箭头,并附上文本$\sigma$
。
我怎样才能实现这些目标?
\documentclass[aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{
arrows,
calc,
chains,
decorations,
decorations.text,
decorations.pathmorphing,
matrix,
positioning,
shapes,
tikzmark
}
\usepackage{tikzpeople}
\begin{document}
\begin{frame}{Protocol View}
\begin{tikzpicture}
\node (e0) at (0,0) {$E_0$};
\node (epk) at (6,0) {$E_{pk}$};
\path[->] (e0) edge node[auto]{$\mathfrak{s}$} (epk);
\uncover<2->{
\node (er) at (3,3) {$E_r$};
\path[->] (e0) edge node[auto]{$\mathfrak{r}$} (er);
}
\uncover<4->{
\path[dashed,->] (epk) edge node[auto,swap]{$\mathfrak{r}\cdot\mathfrak{s}^{-1}$} (er);
\node (b0) at (0,3) {$b = 0$};
\node (b1) at (6,3) {$b = 1$};
}
\end{tikzpicture}
\begin{tikzpicture}[node distance=5cm]
% nodes
\node[alice,minimum size=1cm,] (s) at (0,0) {Alice};
\node[bob,minimum size=1cm,right of=s] (r) {Bob};
% paths
\draw [->,visible on=<2->] (r) -- node [text width=2.5cm,midway,above,align=center] {$E_r$} (s);
\draw [->,visible on=<4->] ($(s.east)+(1em,-1em)$) -- node [text width=2.5cm,midway,align=center] {$0$ or $1$} ($(r.west)+(-1em,-1em)$);
%\draw [->,visible on=<5->] ()
\end{tikzpicture}
\end{frame}
\end{document}
答案1
这将起作用:
\documentclass[aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{
arrows,
calc,
chains,
decorations,
decorations.text,
decorations.pathmorphing,
matrix,
positioning,
shapes,
tikzmark
}
\usepackage{tikzpeople}
\begin{document}
\begin{frame}{Protocol View}
\begin{center}
\begin{tikzpicture}
\node (e0) at (0,0) {$E_0$};
\node (epk) at (6,0) {$E_{pk}$};
\path[->] (e0) edge node[auto]{$\mathfrak{s}$} (epk);
\uncover<2->{
\node (er) at (3,3) {$E_r$};
\path[->] (e0) edge node[auto]{$\mathfrak{r}$} (er);
}
\uncover<4->{
\path[dashed,->] (epk) edge node[auto,swap]{$\mathfrak{r}\cdot\mathfrak{s}^{-1}$} (er);
\node (b0) at (0,3) {$b = 0$};
\node (b1) at (6,3) {$b = 1$};
}
\end{tikzpicture}
\begin{tikzpicture}[node distance=5cm]
% nodes
\node[alice,minimum size=1cm,] (s) at (0,0) {Alice};
\node[bob,minimum size=1cm,right of=s] (r) {Bob};
% paths
\draw [->,visible on=<2->] (r) -- node [text width=2.5cm,midway,above,align=center] {$E_r$} (s);
\draw [->,visible on=<4->] ($(s.east)+(1em,-1.3em)$) -- node [text width=2.5cm,midway,align=center,above] {$0$ or $1$} ($(r.west)+(-1em,-1.3em)$);
\draw [->,visible on=<4->] ($(s.east)+(1em,-2.8em)$) -- node [text width=2.5cm,midway,align=center,above] {$0$ or $1$} ($(r.west)+(-1em,-2.8em)$);
%\draw [->,visible on=<5->] ()
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
我所做的是在图片之间留一条空行,并向below
创建“0 或 1”的节点添加选项。