我想在 Beamer 中突出显示图像的一部分,方法是在图像周围画一个框,并将图像的其余部分设置为暗淡设置。我不知道如何降低图片其余部分的亮度。以下是我的部分尝试,几乎可以完成工作。
但我无法降低左下角小红色矩形外剩余图片的亮度。如能得到任何帮助我将不胜感激。
\documentclass{beamer}
\usetheme{Copenhagen}
\usecolortheme{whale}
\useinnertheme{rounded}
\usepackage{tikz}
\newcounter{boxes}
\newcommand\ordbox[2]{%
\stepcounter{boxes}
\tikz[remember picture,overlay]{
\node[rectangle,rounded corners,line width=2pt,draw=red,fill=pink,text height=10pt,text depth=3pt,align=left,draw opacity = 0.75, fill opacity=.75,text opacity=1] (box-\theboxes) at #2 {#1};}
}
\newcommand\tikzmark[1]{%
\tikz[remember picture,overlay] \node (#1) {};}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.2]{../images/H1D_level_5.pdf}};
\end{tikzpicture}
\end{frame}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.2]{../images/H1D_level_5.pdf}};
\draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
\end{tikzpicture}
\end{frame}
\end{document}
上面的代码产生下面的输出。
答案1
如果在第二张幻灯片中命名节点,则可以使用fill=<color>
with fill opacity=<num>
。通过命名节点,我们可以轻松访问顶点的坐标,以便遍历我们想要填充的区域:
\draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
\fill [draw=none, fill=white, fill opacity=0.3]
(0,0.5) --
(A.north west) -- (A.north east) -- (A.south east) --
(0.5,0) -- (0.5,0.5) -- cycle;
使用修改后的版本并排显示这两幅图像以查看效果:
笔记:
- 为了让图像对齐,我将方框的绘图移动了
0.5\pgflinewidth
。因此,如果您注意到您的投影仪图像在幻灯片之间移动,您也需要应用此移动。 - 即使经过这种调整,第二幅图像似乎还是有点偏差,我不知道原因。所以可能需要再做一次调整。
代码:
\RequirePackage[demo]{graphicx}
\documentclass{beamer}
\usetheme{Copenhagen}
\usecolortheme{whale}
\useinnertheme{rounded}
\usepackage{tikz}
\newcounter{boxes}
\newcommand\ordbox[2]{%
\stepcounter{boxes}
\tikz[remember picture,overlay]{
\node[rectangle,rounded corners,line width=2pt,draw=red,fill=pink,text height=10pt,text depth=3pt,align=left,draw opacity = 0.75, fill opacity=.75,text opacity=1] (box-\theboxes) at #2 {#1};}
}
\newcommand\tikzmark[1]{%
\tikz[remember picture,overlay] \node (#1) {};}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.2]{../images/H1D_level_5.pdf}};
\end{tikzpicture}
\end{frame}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (A) at (0,0) {\includegraphics[scale=0.2]{../images/H1D_level_5.pdf}};
\draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
\fill [draw=none, fill=white, fill opacity=0.3] (0,0.5) -- (A.north west) -- (A.north east) -- (A.south east) -- (0.5,0) -- (0.5,0.5) -- cycle;
\end{tikzpicture}
\end{frame}
\end{document}
代码:
经过修改,生成上面的图像。
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\newcommand\tikzmark[1]{\tikz[remember picture,overlay] \node (#1) {};}
\newcommand*{\Size}{2.5}%
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.1]{./images/EiffelWide.jpg}};
\end{tikzpicture}
%
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (A) at (0,0) {\includegraphics[scale=0.1]{./images/EiffelWide.jpg}};
\draw[red,ultra thick] (0.5\pgflinewidth,0.5\pgflinewidth) rectangle (\Size,\Size);
\fill [draw=none, fill=white, fill opacity=0.4]
(\pgflinewidth,\Size) --
(A.north west) -- (A.north east) -- (A.south east) --
(\Size,\pgflinewidth) -- (\Size,\Size) -- cycle;
\end{tikzpicture}
\end{document}