# Beamer slide effects: including images with \includegraphics<n> leaves undesired space

I am just trying to insert different images of the same side in the same slide, so it gives the effect of just the image changing while the rest of the slide remains the same, including slide number.

For that I use \includegraphics<1>, \includegraphics<2>, \includegraphics<3>, etc.

I am including the images inside a \fbox, and it is leaving an undesired horizontal space that I do not know how to get rid of.

See my MWE:

\documentclass{beamer}

\begin{document}

\begin{frame}
\fbox{\includegraphics[width=.5\linewidth]{example-image-a}}\\
\vspace*{4pt}
\fbox{\includegraphics<1>[width=.5\linewidth]{example-image-a}
\includegraphics<2>[width=.5\linewidth]{example-image-b}
\includegraphics<3>[width=.5\linewidth]{example-image-c}}
\end{frame}

\end{document}


which produces:

Notice the spacing in the images below, how to get rid of it? Thanks!

To get rid of the extra white space, you can add a % sign as shown in the following example:

\documentclass{beamer}

\begin{document}

\begin{frame}
\fbox{\includegraphics[width=.5\linewidth]{example-image-a}}\\
\vspace*{4pt}
\fbox{\includegraphics<1>[width=.5\linewidth]{example-image-a}%
\includegraphics<2>[width=.5\linewidth]{example-image-b}%
\includegraphics<3>[width=.5\linewidth]{example-image-c}}
\end{frame}

\end{document}


More detailed information on the usage of % at the end of lines can be found here: What is the use of percent signs (%) at the end of lines?