User
I am trying to change the shape of the highlighted area to a rectangle in the MWE below.


\documentclass{beamer}
\usepackage{tikz}

\tikzset{
use page relative coordinates/.style={
shift={(current page.south west)},
x={(current page.south east)},
y={(current page.north west)}
},
}

\begin{document}

\begin{frame}{title}{subtitle}
\begin{block}{Block title}
Some content
\end{block}
\includegraphics[width=0.5\textwidth]{example-image-a}
\begin{tikzpicture}[remember picture,overlay,use page relative coordinates]
\fill[opacity=0.5,black] (0,0) rectangle (1,1) (0.25,0.5) circle (2cm);
\end{tikzpicture}
\end{frame}
\end{document}


Neither


\begin{tikzpicture}[remember picture,overlay,use page relative coordinates]
\fill[opacity=0.5,black] (0,0) rectangle (1,1) (0.15,0.15) rectangle (0.2,0.2);
\end{tikzpicture}


nor


\begin{tikzpicture}[remember picture,overlay,use page relative coordinates]
\fill[opacity=0.5,black] (0,0) rectangle (1,1);
\fill[opacity=0,black] (0.15,0.15) rectangle (0.2,0.2);
\end{tikzpicture}


does the job.

How can I get it working?
samcarter
You can use the even odd rule to get your code to work:


\documentclass{beamer}
\usepackage{tikz}

\tikzset{
use page relative coordinates/.style={
shift={(current page.south west)},
x={(current page.south east)},
y={(current page.north west)}
},
}

\begin{document}

\begin{frame}
\frametitle{title}
\framesubtitle{subtitle}
\begin{block}{Block title}
Some content
\end{block}
\includegraphics[width=0.5\textwidth]{example-image-a}
\begin{tikzpicture}[even odd rule,remember picture,overlay,use page relative coordinates]
\fill[opacity=0.5,black] (0,0) rectangle (1,1) (0.15,0.15) rectangle (0.2,0.2);
\end{tikzpicture}
\end{frame}
\end{document}


![document.png](/image?hash=095ca2acc4ed4e3be2284c7468488e4db97d64f315fd1c921a9f838258b440c2)

### Some background:

The TikZ user manual has the following to say about the default filling mechanism in 15.5.2 Graphic Parameters: Interior Rules

Your attempts with two squares are basically like the lower example. If you force one of your rectangles to be drawn in the other direction (e.g. by flipping one of the coordinates) you'll see that you will get your rectangular spotlight (but I think using the even odd rule is easier):


\documentclass{beamer}
\usepackage{tikz}

\tikzset{
use page relative coordinates/.style={
shift={(current page.south west)},
x={(current page.south east)},
y={(current page.north west)}
},
}

\begin{document}

\begin{frame}
\frametitle{title}
\framesubtitle{subtitle}
\begin{block}{Block title}
Some content
\end{block}
\includegraphics[width=0.5\textwidth]{example-image-a}
\begin{tikzpicture}[remember picture,overlay,use page relative coordinates]
\fill[opacity=0.5,black] (0,0) rectangle (1,1) (0.2,0.15) rectangle (0.15,0.20);
\end{tikzpicture}
\end{frame}
\end{document}


Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.