# How to move tikzpicture horizontally and vertically?

I have a beamer frame as shown below. The problem is that tikzpicture is a bit more down, and it covers my items. How can I move the whole tikzpicture a bit horizontally to center and also vertically in order not to overlap with my itemized text?

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


You could

• use the overlay option for the text below the left node and the loop. This will make sure that your tikzpicture is centred with respect to the two tikzpeople - which makes the whole picture look centred (even if it was actually centred before)

• add some extra space above and below the tikzpicture as needed, e.g. with \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{metropolis}

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


• Sorry, I forgot to mention, I have \usetheme{metropolis}, and this puts the loop over the header, so is not fully visible. And idea how to push it a bit more down? Dec 9, 2022 at 14:32
• @pixel please see my updated answer. Dec 9, 2022 at 14:37