使用 Tikzpicture 放大幻灯片中的多张图片之一

使用 Tikzpicture 放大幻灯片中的多张图片之一

我想放大我分成 3 列的 12 张图片中的一张。每列有 4 张图片,高度和宽度均相同。

有一张图片我想放大并在幻灯片中心以圆圈突出显示。

我一直试图使用 来实现这一点tikzpicture,但正如您在 中看到的MWE,缩放并没有“叠加”在幻灯片上,而是干扰了其他图像的组织。除此之外,我没有放大整个图像,而是放大了其中的一部分。

我该如何修复我的代码以达到我想要的最终结果?

\documentclass[10pt, compress]{beamer}
\usepackage{tikz}
\usetikzlibrary{spy}


\begin{frame}

\begin{columns}[t]
\column{.3\textwidth}
\centering
\includegraphics[width=3cm,height=1.75cm]{img1}\\
\includegraphics[width=3cm,height=1.75cm]{img2}\\
\includegraphics[width=3cm,height=1.75cm]{img3}\\
\includegraphics[width=3cm,height=1.75cm]{img4}
\column{.3\textwidth}
\centering
\includegraphics[width=3cm,height=1.75cm]{img5}\\
\includegraphics[width=3cm,height=1.75cm]{img6}\\
\includegraphics[width=3cm,height=1.75cm]{img7}\\
\includegraphics[width=3cm,height=1.75cm]{img8}\\
\column{.3\textwidth}
\centering
\includegraphics[width=3cm,height=1.75cm]{img9}\\
%%% this is the image that I want to zoom in on
\begin{tikzpicture}[
spy using outlines={
  circle,
  magnification=10,
  size=5cm,
  connect spies}]
\node[inner sep=0pt] {\pgfimage[width=3cm,height=1.75cm]{img10}};
\only<2>{\spy[red!70!black] on (0.88,0.15) in node at (.5\textwidth,0);}
\end{tikzpicture}
\includegraphics[width=3cm,height=1.75cm]{img11}\\
\includegraphics[width=3cm,height=1.75cm]{img12}\\

\end{columns}
\end{frame}
\end{document}

基本上,我的主要问题是如何放大上面 12 张图像中的一张?

以下是目前发生的情况: 代码出错

答案1

使用overlay选项tikzpicture;如果您另外使用remember picture,现在您就可以访问current page节点,并且可以将望远镜放在上面current page.center,例如(最后一部分当然是可选的;您也可以使用绝对坐标将放大镜放在框架上的任何位置);重要的是将望远镜放在不会被在望远镜之后添加的物体占用的空间中(否则,那些物体会与望远镜重叠)。

以下是一个小例子:

\documentclass[10pt, compress]{beamer}
\usepackage{tikz}
\usetikzlibrary{spy}

\begin{document}

\begin{frame}

\begin{columns}[t]
\column{.3\textwidth}
  \centering
  \includegraphics[width=3cm,height=1.75cm]{example-image-a}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-a}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-a}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-a}
\column{.3\textwidth}
  \centering
  \includegraphics[width=3cm,height=1.75cm]{example-image-b}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-b}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-b}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-b}\\
\column{.3\textwidth}
  \centering
  \includegraphics[width=3cm,height=1.75cm]{example-image-c}\\
  \parbox[c][1.75cm][c]{3cm}{%
    \begin{tikzpicture}[
      overlay,
      remember picture,
      spy using outlines={%
        circle,
        magnification=10,
        size=5cm,
        connect spies
        }
    ]
    \node[
      inner sep=0pt,
      anchor=west,
      outer sep=0pt
    ] 
    {\pgfimage[width=3cm,height=1.75cm]{example-image-c}};
    \only<2>{%
      \spy[red!70!black] on (1.4,0.15) in node at (current page.center);
    }
    \end{tikzpicture}%
  }\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-c}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-c}
\end{columns}

\end{frame}

\end{document}

输出的动画:

在此处输入图片描述

如果要放大整个图像,可以调整magnificationwidthheight键(width= magnificationx image widthheight= magnificationx image height):

\documentclass[10pt, compress]{beamer}
\usepackage{tikz}
\usetikzlibrary{spy}

\begin{document}

\begin{frame}

\begin{columns}[t]
\column{.3\textwidth}
  \centering
  \includegraphics[width=3cm,height=1.75cm]{example-image-a}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-a}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-a}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-a}
\column{.3\textwidth}
  \centering
  \includegraphics[width=3cm,height=1.75cm]{example-image-b}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-b}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-b}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-b}\\
\column{.3\textwidth}
  \centering
  \includegraphics[width=3cm,height=1.75cm]{example-image-c}\\
  \parbox[c][1.75cm][c]{3cm}{%
    \begin{tikzpicture}[
      overlay,
      remember picture,
      spy using outlines={%
        magnification=2.5,
        width=7.5cm,
        height=4.375cm,
        connect spies
        }
    ]
    \node[
      inner sep=0pt,
      anchor=west,
      outer sep=0pt
    ] (a)
    {\pgfimage[width=3cm,height=1.75cm]{example-image-c}};
    \only<2>{%
      \spy[red!70!black] on (1.5,0) in node at ([xshift=-2cm]current page.center);
    }
    \end{tikzpicture}%
  }\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-c}\\
  \includegraphics[width=3cm,height=1.75cm]{example-image-c}
\end{columns}

\end{frame}

\end{document}

在此处输入图片描述

相关内容