3

Related to this question, I am trying to put a logo on the top right side of each slide in a beamer document.

This is my code:

\documentclass[10pt]{beamer}
% This is the file main.tex
\usetheme{Warsaw}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{tikz}
\setbeamertemplate{navigation symbols}{}%remove navigation symbols
\setbeamercovered{transparent}
\makeatother
%\pgfdeclareimage[height=0.45cm]{logo}{figures/ubuntu-logo32}
%\logo{\pgfuseimage{logo}}
\title{title}
\author{Name Surname}
\institute{Institute\\[\medskipamount]\includegraphics[scale=0.2]{figures/ubuntu-logo32.png}}
%\email{[email protected]}
\date{date\\ place}
\begin{document}

\begin{frame}
\titlepage
\end{frame}

\addtobeamertemplate{frametitle}{}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north east,yshift=-6pt] at (current page.north east) {\includegraphics[scale=0.07]{figures/ubuntu-logo32.png}};
\end{tikzpicture}
}

\frame{
\transsplitverticalin
\frametitle{Summary}\tableofcontents
}

\section{Section}
\frame{\sectionpage}
\subsection{subsection}
\frame{
\frametitle{title}
\begin{block}{title}
title
\begin{itemize}
\item {title};
\item {title};
\item {title};
\item {title};
\end{itemize}
\end{block}

\begin{alertblock}{title}
title
\begin{itemize}
\item {title};
\end{itemize}
\end{alertblock}

\begin{exampleblock}{title}
title
\begin{itemize}
\item {title};
\item {title};
\item {title};
\item {title};
\end{itemize}
\end{exampleblock}
}
\end{document}

However, I noticed the following issues:

1) I have to manually select the position of the logo, which is a bit annoying. Is there any automatic way to position the logo?

2) It seems that my code "steal" some space before the first block. This is a particularly undesired effect, since it reduces the overall space for content. This is the difference between the slide with the logo:

enter image description here

and the slide without the logo:

enter image description here

How could I reduce the space above the first block without removing the logo on the top right of the slide?

3
  • 1
    Concerning your second question: just put \vspace*{-0.5cm} after \end{tikzpicture} to reduce the space between the frametitle and the content. Commented Aug 24, 2015 at 14:27
  • It seems to be good.
    – werty
    Commented Aug 24, 2015 at 14:45
  • You're adding a space to the template, even though the tikzpicture itself takes no space.
    – cfr
    Commented Nov 6, 2016 at 4:41

1 Answer 1

3

Instead of using this tikz approach and dealing with the additional vertical space, you could add your logo to the definition of the frametitle

\documentclass[10pt]{beamer}

\usetheme{Warsaw}
\setbeamertemplate{navigation symbols}{}%remove navigation symbols

\makeatletter
\setbeamertemplate{frametitle}{%
    \nointerlineskip%
    \vskip-2pt%
    \hbox{\leavevmode
        \advance\beamer@leftmargin by -12bp%
        \advance\beamer@rightmargin by -12bp%
        \beamer@tempdim=\textwidth%
        \advance\beamer@tempdim by \beamer@leftmargin%
        \advance\beamer@tempdim by \beamer@rightmargin%
        \hskip-\Gm@lmargin\hbox{%
            \setbox\beamer@tempbox=\hbox{\begin{minipage}[b]{.92\paperwidth}%
                    \vbox{}\vskip-.75ex%
                    \leftskip0.3cm%
                    \rightskip0.3cm plus1fil\leavevmode
                    \insertframetitle%
                    \ifx\insertframesubtitle\@empty%
                    \strut\par%
                    \else
                    \par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
                    \fi%
                    \nointerlineskip
                    \vbox{}%
                \end{minipage}%
                \hfill%
                \raisebox{.1cm}{\includegraphics[height=.5cm]{example-image}}%
                }%
                \beamer@tempdim=\ht\beamer@tempbox%
                \advance\beamer@tempdim by 2pt%
                \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
                    \usebeamercolor{frametitle right}
                    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
                    \pgfusepath{clip}
                    \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
                \end{pgfpicture}
                \hskip-\paperwidth%
                \box\beamer@tempbox%
            }%
            \hskip-\Gm@rmargin%
        }%
        \nointerlineskip
        \vskip-0.2pt
        \hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@topshade}\hskip-\Gm@rmargin}
        \vskip-2pt
    }
\makeatother


\begin{document}

    \frame{
        \frametitle{title}
        \begin{block}{title}
            title
            \begin{itemize}
                \item {title};
                \item {title};
                \item {title};
                \item {title};
            \end{itemize}
        \end{block}

        \begin{alertblock}{title}
            title
            \begin{itemize}
                \item {title};
            \end{itemize}
        \end{alertblock}

        \begin{exampleblock}{title}
            title
            \begin{itemize}
                \item {title};
                \item {title};
                \item {title};
                \item {title};
            \end{itemize}
        \end{exampleblock}
    }
\end{document}

enter image description here

7
  • When not using any theme I get ! Package pgf Error: Undefined shading "beamer@frametitleshade". What to do?
    – Viesturs
    Commented Jan 26, 2018 at 17:06
  • @Viesturs Then you better change the frametitel definition of the default theme you are using and not the one of another theme. Commented Jan 26, 2018 at 17:10
  • Wheres is the frame title definition of the default them?
    – Viesturs
    Commented Jan 26, 2018 at 17:14
  • @Viesturs in beamerouterthemedefault.sty Commented Jan 26, 2018 at 17:17
  • How do I navigate the logo to the position intended? By using \hfill and \vspace?
    – Viesturs
    Commented Jan 26, 2018 at 17:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .