我有一个如下所示的投影仪框架。它绘制了两个节点tikzpeople
,然后在它们之间绘制了箭头。但是,我想绘制另外两个东西。首先,我想在左侧图标下方添加多行文本,并在右侧图标上方绘制带注释的圆形箭头。我想要实现的目标如下图所示。
\documentclass[xcolor=table,10pt,aspectratio=169]{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{amsmath,amssymb,amsthm}
\usepackage[beamer,customcolors]{hf-tikz}
\usepackage{booktabs} % Tables
\usepackage{tikz}
\usetikzlibrary{
arrows,
calc,
chains,
decorations,
decorations.text,
decorations.pathmorphing,
matrix,
overlay-beamer-styles,
positioning,
shapes,
tikzmark
}
\usepackage{tikzpeople}
\tikzset{hl/.style={
set fill color=red!80!black!40,
set border color=red!80!black,
},
}
\begin{document}
\begin{frame}{Security Notion - IND-CPA-FE}
\begin{center}
\begin{tikzpicture}[every text node part/.style={align=center}]
\node[name=a,charlie,minimum size=2cm] (A) at (0,0) {$(\mathsf{msk},\mathsf{mpk}) \gets \mathsf{Setup}(1^\lambda, \mathcal{F})$};
\node[name=b,devil,minimum size=2cm] (B) at (10,0) {};
\uncover<2->{\draw[->] (1.5,1.25) -- (8,1.25) node[midway, above]{$\mathsf{mpk}$};}
\uncover<3->{\draw[->] (8,0.5) -- (1.5,0.5) node[midway, above]{$x_0^*, x_1^*$};}
\uncover<4->{\draw[->] (1.5,-0.25) -- (8,-0.25) node[midway, above]{$c^* \gets \mathsf{Enc}(\mathsf{mpk}, x_b^*)$};}
\uncover<5->{\draw[->] (8,-1) -- (1.5,-1) node[midway, above]{$b'$};}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
答案1
标准循环和自定义循环:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikzpeople}
\begin{document}
\begin{tikzpicture}
\node[charlie, minimum size=2cm, align=center] (A) at (0,0) {$(\mathsf{msk},\mathsf{mpk}) \gets \mathsf{Setup}(1^\lambda, \mathcal{F})$\\Text also here} edge[loop above] node {Text} ();
\node[devil, minimum size=2cm] (B) at (5,0) {};
\draw[->] (B) to[out=45, in=90, looseness=5] node[above right]{Text} (B);
\end{tikzpicture}
\end{document}
答案2
以下是我的想法:
\documentclass[xcolor=table,10pt,aspectratio=169]{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{amsmath,amssymb,amsthm}
\usepackage[beamer,customcolors]{hf-tikz}
\usepackage{booktabs} % Tables
\usepackage{tikz}
\usetikzlibrary{
arrows,
calc,
chains,
decorations,
decorations.text,
decorations.pathmorphing,
matrix,
overlay-beamer-styles,
positioning,
shapes,
tikzmark
}
\usepackage{tikzpeople}
\tikzset{hl/.style={
set fill color=red!80!black!40,
set border color=red!80!black,
},
}
\usepackage{lipsum}
\begin{document}
\begin{frame}{Security Notion - IND-CPA-FE}
\begin{center}
\begin{tikzpicture}[every text node part/.style={align=center}]
\node[name=a,charlie,minimum size=2cm] (A) at (0,0) {$(\mathsf{msk},\mathsf{mpk}) \gets \mathsf{Setup}(1^\lambda, \mathcal{F})$ \\Hello is anybody out there ?};
\node[name=b,devil,minimum size=2cm] (B) at (10,0) {};
{\draw[->] (1.5,1.25) -- (8,1.25) node[midway, above]{$\mathsf{mpk}$};}
{\draw[->] (8,0.5) -- (1.5,0.5) node[midway, above]{$x_0^*, x_1^*$};}
{\draw[->] (1.5,-0.25) -- (8,-0.25) node[midway, above]{$c^* \gets \mathsf{Enc}(\mathsf{mpk}, x_b^*)$};}
{\draw[->] (8,-1) -- (1.5,-1) node[midway, above]{$b'$};}
\path[->] (B) edge [loop above] +(0,0);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
Tiks 有一个不错的loop
选择:https://tikz.dev/library-automata
所以我补充道(B) edge [loop above] +(0,0);
多行文本更简单:
\\Hello is anybody out there ?}
您还可以添加选项[text width = 50]
以获得所需的效果。
当然还有其他方法可以实现这一点。