我想绘制一种协议流,其中有两方,每方都向另一方发送一条消息。一个箭头应该在另一个箭头上方,两个箭头上方都应该有一些文本。此外,我想在节点的下方和上方都写上文本。目前,我只在下面有文本。我希望该文本位于上方,而我想在下面写两行数学方程式。我如何用 TikZ 实现这些?目前,我收到错误:
pgfkeys 错误:我不知道密钥“/tikz/line”,我将忽略它。也许你拼错了。
\documentclass{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 distance=5cm]
% nodes
\node[alice,minimum size=1.5cm] (s) at (0,0) {Alice};
\node[bob,minimum size=1.5cm,right of=s] (r) {Bob};
% paths
\path [line] (r) -- node [text width=2.5cm,midway,above,align=center] {$\hat{\sigma}$} (s);
\path [line] (s) -- node [text width=2.5cm,midway,above,align=center] {$\sigma$} (r);
\end{tikzpicture}
\end{frame}
\end{document}
答案1
\documentclass{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 distance=5cm]
% nodes
\node[alice,minimum size=1.5cm, label=90:text] (s) at (0,0) {Alice};
\node[bob,minimum size=1.5cm,right of=s, label=90:text] (r) {Bob};
% paths
\draw [->] (r) -- node [text width=2.5cm,midway,above,align=center] {$\hat{\sigma}$} (s);
\draw [->] ($(s.east)+(1em,-1em)$) -- node [text width=2.5cm,midway,below,align=center] {$\sigma$} ($(r.west)+(-1em,-1em)$) ;
\end{tikzpicture}
\end{frame}
\end{document}