如何水平和垂直移动 tikzpicture?

如何水平和垂直移动 tikzpicture?

我有一个如下所示的投影仪框架。问题是它tikzpicture稍微向下一点,遮住了我的项目。我怎样才能将整个框架tikzpicture水平移动到中心,同时垂直移动,以免与我的项目文本重叠?

\documentclass[xcolor=table,10pt,aspectratio=169]{beamer}
\usetheme{metropolis} 

\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,align=center] (A) at (0,0) {$(\mathsf{msk},\mathsf{mpk}) \gets \mathsf{Setup}(1^\lambda, \mathcal{F})$ \\ $b \gets \{0,1\}$};
\node[name=b,devil,minimum size=2cm] (B) at (9,0) {};
\uncover<2->{\draw[->] (1.5,1.25) -- (7,1.25) node[midway, above]{$\mathsf{mpk}$};
\draw[->] (B) to[out=45, in=90, looseness=5] node[above right]{\alt<7->{$\mathcal{O}$}{$\mathcal{O}_{\mathsf{KeyGen}}(\cdot)$}} (B);}
\uncover<3->{\draw[->] (7,0.5) -- (1.5,0.5) node[midway, above]{$x_0^*, x_1^*$};}
\uncover<4->{\draw[->] (1.5,-0.25) -- (7,-0.25) node[midway, above]{$c^* \gets \mathsf{Enc}(\mathsf{mpk}, x_b^*)$};}
\uncover<5->{\draw[->] (7,-1) -- (1.5,-1) node[midway, above]{$b'$};}
\end{tikzpicture}
\end{center}
\begin{itemize}
    \uncover<6>{
    \item Validity of adversary: no $f$ queried to $\mathcal{O}_{\mathsf{KeyGen}}(\cdot)$ such that $f(x_0^*) \neq f(x_1^*)$.
    \item Winning condition: $b = b'$ and adversary is valid.
    }
\end{itemize}
\end{frame}
\end{document}

答案1

你可以

  • 使用overlay左节点下方的文本选项和循环。这将确保您的 tikzpicture 相对于两个 tikzpeople 居中 - 这使得整个图片居中(即使之前已经居中)

  • 根据需要在 tikzpicture 的上方和下方添加一些额外的空间,例如\vspace*{...}

\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,
  },
}

\usetheme{moloch}% modern fork of the metropolis theme

\begin{document}


\begin{frame}{Security Notion - IND-CPA-FE}

\vspace*{1.5cm}

\begin{center}
\begin{tikzpicture}[every text node part/.style={align=center}]
\node[name=a,charlie,minimum size=2cm,align=center] (A) at (0,0) {};
\node[below=0cm of A,overlay] {$(\mathsf{msk},\mathsf{mpk}) \gets \mathsf{Setup}(1^\lambda, \mathcal{F})$ \\ $b \gets \{0,1\}$};
\node[name=b,devil,minimum size=2cm] (B) at (9,0) {};
\uncover<2->{\draw[->] (1.5,1.25) -- (7,1.25) node[midway, above]{$\mathsf{mpk}$};
\draw[->,overlay] (B) to[out=45, in=90, looseness=5] node[above right]{\alt<7->{$\mathcal{O}$}{$\mathcal{O}_{\mathsf{KeyGen}}(\cdot)$}} (B);}
\uncover<3->{\draw[->] (7,0.5) -- (1.5,0.5) node[midway, above]{$x_0^*, x_1^*$};}
\uncover<4->{\draw[->] (1.5,-0.25) -- (7,-0.25) node[midway, above]{$c^* \gets \mathsf{Enc}(\mathsf{mpk}, x_b^*)$};}
\uncover<5->{\draw[->] (7,-1) -- (1.5,-1) node[midway, above]{$b'$};}
%\draw[green] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\end{center}

\vspace*{0.8cm}

\begin{itemize}[<6>]
    \item Validity of adversary: no $f$ queried to $\mathcal{O}_{\mathsf{KeyGen}}(\cdot)$ such that $f(x_0^*) \neq f(x_1^*)$.
    \item Winning condition: $b = b'$ and adversary is valid.
\end{itemize}
\end{frame}
\end{document}

enter image description here

相关内容