如何将 tikz 图片置于 beamer slide 的中心并在其上绘图?

如何将 tikz 图片置于 beamer slide 的中心并在其上绘图?

我想将 PNG 图片添加到幻灯片中,并使用 tikz 覆盖在其上进行绘制。我需要在添加 tikz 绘图时保持图像静止在页面中心。

但是,我无法将图像放置在幻灯片的中心。此外,当我在图像上添加 tikz 图形时,图像会移动。

如何设置图形上形状的坐标也不清楚。

我怎样才能将图形放置在幻灯片的中心并在其上的某些坐标处包含 tikz 形状?谢谢!

梅威瑟:

\documentclass[t,aspectratio=169]{beamer}
\usetheme{metropolis}

\usepackage{tikz}
\usepackage{graphicx}
\usepackage{xcolor}

\begin{document}

\begin{frame}[c,plain]
\frametitle{New}

\begin{center}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[width=0.4\textwidth]{example-image}};
\end{tikzpicture}
\end{center}

\begin{tikzpicture}
\draw[red,fill=black!2] (1,1) rectangle (2,5);
\draw[thick, -latex] (3,3) to (4,4);
\end{tikzpicture}

\end{frame}%

\end{document}

如图

答案1

如果您希望图像位于页面的中心,您可以将其定位在current page.center

\documentclass[t,aspectratio=169]{beamer}
\usetheme{moloch}% modern fork of the metropolis theme

\usepackage{tikz}
%\usepackage{graphicx}
%\usepackage{xcolor}

\begin{document}

\begin{frame}[c,plain]
\frametitle{New}

\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[width=0.4\textwidth]{example-image}};
\draw[red,fill=black!2] (1,-2) rectangle (2,2);
\draw[thick, -latex] (3,1) to (4,2);
\end{tikzpicture}

\end{frame}

\end{document}

相关内容