2

I wanted to add a logo at the top right corner of my frames so I edited the frametitle with \addtobeamertemplate{frametitle} and added the logo using a TikZ \node (as explained in this answer), like this:

\addtobeamertemplate{frametitle}{}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north east,yshift=2pt] at (current page.north east) {\includegraphics[height=0.8cm]{example-image}};
\end{tikzpicture}}

The problem is that this modification adds an additional space between the frametitle and the body of the frame, thus wasting very valuable space.

This is how my frame looks before adding the \addtobeamertemplate{frametitle} block:

before

And this is how it looks after adding it (notice the wider gap):

after

How can I remove that gap?


Here is my MWE:

\documentclass{beamer}
\usetheme{Madrid}

\usepackage{tikz}

\addtobeamertemplate{frametitle}{}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north east,yshift=2pt] at (current page.north east) {\includegraphics[height=0.8cm]{example-image}};
\end{tikzpicture}}

\begin{document}

\begin{frame}
\frametitle{Frame title}
\includegraphics[height=\textheight]{example-image}
\end{frame}

\end{document}
2

An overlay tikzpicture doesn't occupy space but it is nevertheless a box and so one must be careful where to insert it. In vertical mode (like here) it will create an additional line. I would use the footline template (and its second argument) to inject the logo:

\documentclass{beamer}
\usetheme{Madrid}

\usepackage{tikz}


\addtobeamertemplate{footline}{%
\leavevmode\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north east,yshift=2pt] at (current page.north east) {\includegraphics[height=0.8cm]{example-image}};
\end{tikzpicture}\ignorespaces% \ignorespaces needed because of spurious space in the template
}{}

\begin{document}

\begin{frame}
\frametitle{Frame title}
\includegraphics[height=\textheight]{example-image}

\end{frame}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.