4

I am using the solution from this question: Positioning logo in the front page as well as slides to add a logo on the top right of the title frame.

My problem is a bit more complicated:

  • I have a set of 4 logos (pdf and png)
  • some slides should not have any logo
  • some should have 1 logo
  • some should have more than 1 logo (aligned horizontally on the top right of the title bar)

I am using:

 \usetheme[height=9mm]{Rochester} 

and I am using many time the subtitles.

I have copied-and-pasted the MWE from the linked answer:

\documentclass{beamer}
\usetheme[height=9mm]{Rochester} 
\usecolortheme{beaver}
\usepackage{tikz}

\title{The title}
\institute[Inst.]{The Institute}
\date{\today}

\begin{document}


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

\begin{frame}{Motivation}
Now the logo is visible
\end{frame}

\begin{frame}{Motivation}
\framesubtitle{A}
Now the logo is visible
\end{frame}

\end{document}
  • 2
    Welcome to TeX.SX! It is easier to help you if you add a minimal working example that takes the form \documentclass{...}\usepackage{....}\begin{document}...\end{document}. If possible, it should compile and have the minimum amount of code needed to illustrate your problem. This makes it much easier for people to troubleshoot your problem - and much more likely that they will! Here it would help to know how you are adding and placing your logo and to have something to start from. – Andrew Aug 20 '15 at 12:48
  • sorry, but I think my answer is pretty clear. It is just a variation of the linked question. How to include more than one logo? How to disable logo on some slides? You can take the minimal working example from the linked answer. – wiso Aug 20 '15 at 14:27
  • 1
    Wiso, if you want people to help you it is in your interest to make it easy for them. Of course, you don't have to do this if you don't want to. – Andrew Aug 20 '15 at 15:29
  • 1
    I can see to ways, either reset the corresponding beamer template on the slides which should not show a logo or have an empty transparent image as default logo and change the image locally. For showing how to do this is beamer it would be very convenient to have a MWE to start with. – user36296 Aug 20 '15 at 21:05
6

You could define the frametitle template so it puts the logos by fetching which ones from a macro that you redefine at the right points.

\documentclass{beamer}
\usetheme[height=9mm]{Rochester}
\usecolortheme{beaver}
\usepackage{tikz}

\title{The title}
\institute[Inst.]{The Institute}
\date{\today}

\def\thisframelogos{}

\newcommand{\framelogo}[1]{\def\thisframelogos{#1}}

\addtobeamertemplate{frametitle}{}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north east,yshift=2pt] at (current page.north east) {%
    \foreach \img in \thisframelogos {%
        \hspace{.5ex}%
        \includegraphics[height=0.8cm]{\img}%
    }%
};
\end{tikzpicture}}


\begin{document}

\begin{frame}{Motivation}
No logo
\end{frame}

\framelogo{cat}

\begin{frame}{Motivation}
Now the logo is visible
\end{frame}

\framelogo{cat,cat}

\begin{frame}{Motivation}
\framesubtitle{A}
Now we have two logos
\end{frame}

\end{document}

The \thisframelogos macro stores the list of images you would like to put in the title of the next frames. The \framelogo macro just sets \thisframelogos.

When \thisframelogos is changed every frame created after the change will use its contents as the list of images to put. The images are put using a \foreach command which is defined in tikz.

To remove any logo just use \framelogo{} before your frame.

As a key for frame

To make the trick non "stateful" but applicable per-frame we can define a custom key and reset the \thisframelogos with the help of etoolbox (see this)

\documentclass{beamer}
\usetheme[height=9mm]{Rochester}
\usecolortheme{beaver}
\usepackage{tikz}
\usepackage{etoolbox}

\title{The title}
\institute[Inst.]{The Institute}
\date{\today}

\newcommand{\framelogo}[1]{\def\thisframelogos{#1}}

\addtobeamertemplate{frametitle}{}{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north east,yshift=2pt] at (current page.north east) {%
    \foreach \img in \thisframelogos {%
        \hspace{.5ex}%
        \includegraphics[height=0.8cm]{\img}%
    }%
};
\end{tikzpicture}}

\BeforeBeginEnvironment{frame}{\framelogo{}}


\makeatletter
\define@key{beamerframe}{logos}[true]{\framelogo{#1}}
\makeatother


\begin{document}

\begin{frame}{Motivation}
No logo
\end{frame}

\begin{frame}[logos=cat]{Motivation}
Now the logo is visible
\end{frame}

\begin{frame}{Motivation}
No logo again
\end{frame}

\begin{frame}[logos={cat,cat}]{Motivation}
\framesubtitle{A}
Now we have two logos
\end{frame}

\end{document}
  • In general I don't like solution with state: I would like to specify for every slide if I want a logo. If I specify nothing I want no logo (and not the logo in the previous slide). Suppose for example I want to reshuffle my slides. – wiso Aug 21 '15 at 0:05
  • @wiso I edited to support your added requirement – Bordaigorl Aug 21 '15 at 0:36
  • 3
    @wiso You could at least say something nice before criticising an answer on the grounds that its author failed to read your mind accurately. A stateful solution is, I think, the obvious one here. (Certainly I use a stateful solution for this in my own slides, although I never use two logos in the same place.) At the very least, you did not make it at all clear in your question that you did not want the flexibility this provides. Normally, this is how logos work in Beamer - it is how the default logo works, for example. – cfr Aug 21 '15 at 0:50
2

This is a similar idea to other answers, implemented using the list features provided by etoolbox.

I define three new user-level commands for configuring the logo.

\setmylogo{}

This command sets a comma-separated list of images as the current logo (to be used until further notice, if used outside a frame environment). For example,

\setmylogo{logo1,logo2}

To clear the logos, you can use an empty argument i.e. \setmylogo{}.

The second command is

\addlogoleft{}

This adds a comma-separated list of images to the left of the existing logo. For example, if the logo is logo1,logo2, then

\addlogoleft{logo0}

will set the logo image list to logo0,logo1,logo2.

Similarly

\addlogoright{}

adds a comma-separated list of images to the right of the existing logo.

Here's a complete example:

\documentclass{beamer}
\usetheme[height=9mm]{Rochester}
\usecolortheme{beaver}
\usepackage{tikz,etoolbox}
\title{The title}
\institute[Inst.]{The Institute}
\date{\today}
\newcommand*\mylogo{%
  \renewcommand*\do[1]{\includegraphics[height=8mm]{##1}}%
  \dolistloop\mylogolist}
\newcommand*\setmylogo[1]{%
  \renewcommand*\mylogolist{}%
  \forcsvlist{\listadd\mylogolist}{#1}}
\newcommand*\addlogoleft[1]{%
  \global\let\oldmylogolist\mylogolist
  \renewcommand*\mylogolist{}%
  \forcsvlist{\listadd\mylogolist}{#1}%
  \forcsvlist{\listeadd\mylogolist}{\oldmylogolist}}
\newcommand*\addlogoright[1]{%
  \forcsvlist{\listadd\mylogolist}{#1}}
\newcommand*\mylogolist{}
\begin{document}
  \addtobeamertemplate{frametitle}{}{%
    \begin{tikzpicture}[remember picture,overlay]
      \node[anchor=north east,yshift=2pt] at (current page.north east) {\mylogo};
    \end{tikzpicture}}
  \begin{frame}{Motivation}
    No tiger.
  \end{frame}
  \setmylogo{tiger}
  \begin{frame}{Motivation}{A}
    Lone tiger.
  \end{frame}
  \addlogoleft{tiger,example-image-a}
  \begin{frame}{Mix}
    Lone tiger with document.
  \end{frame}
  \addlogoright{example-image-b,example-image-c}
  \begin{frame}{Mix}
    Lone tiger with documents.
  \end{frame}
  \setmylogo{tiger,tiger,tiger,tiger}
  \begin{frame}{Multiplication}
    Lots of tigers.
  \end{frame}
  \setmylogo{}
  \begin{frame}{None}
    No tiger.
  \end{frame}
\end{document}

tigers and more

EDIT

Since you apparently don't want anything quite this flexible but prefer to specify the logo for each frame on which it is required, here's a simplified version. In this case, just use \setmylogo{} with a comma-separated list of images inside the relevant frame environment:

\documentclass{beamer}
\usetheme[height=9mm]{Rochester}
\usecolortheme{beaver}
\usepackage{tikz,etoolbox}
\title{The title}
\institute[Inst.]{The Institute}
\date{\today}
\newcommand*\mylogo{%
  \renewcommand*\do[1]{\includegraphics[height=8mm]{##1}}%
  \tikz[remember picture, overlay]\node[anchor=north east, yshift=2pt] at (current page.north east) {\dolistloop\mylogolist};}
\newcommand*\setmylogo[1]{%
  \renewcommand*\mylogolist{}%
  \forcsvlist{\listadd\mylogolist}{#1}%
  \mylogo}
\newcommand*\mylogolist{}
\begin{document}
  \begin{frame}{Motivation}
    No tiger.
  \end{frame}
  \begin{frame}{Motivation}{A}
  \setmylogo{tiger}
    Lone tiger.
  \end{frame}
  \begin{frame}{Mix}
  \setmylogo{tiger,example-image-a}
    Lone tiger with document.
  \end{frame}
  \begin{frame}{Mix}
  \setmylogo{example-image-b,example-image-c}
    Lone tiger with documents.
  \end{frame}
  \begin{frame}{Multiplication}
  \setmylogo{tiger,tiger,tiger,tiger}
    Lots of tigers.
  \end{frame}
  \begin{frame}{None}
    No tiger.
  \end{frame}
\end{document}

Notice that there is no need for \setmylogo{} in the final frame as the standard default is no logo.

fewer tigers

1

Based on Passing arguments to custom frame option you can define custom beamer templates for the frametitle and chose them via frameoptions

\documentclass{beamer}
\usetheme[height=9mm]{Rochester} 
\usecolortheme{beaver}
\usepackage{tikz}
\usepackage{etoolbox}

\title{The title}
\institute[Inst.]{The Institute}
\date{\today}

\makeatletter
\defbeamertemplate{frametitle}{mydefault}
{
    \vspace*{-1cm}%
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \begin{beamercolorbox}[sep=0.3cm,left,wd=\the\@tempdima]{frametitle}
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-1ex%
    \if@tempswa\else\csname beamer@fteleft\endcsname\fi%
    \strut\insertframetitle\strut\par%
    {%
        \ifx\insertframesubtitle\@empty%
        \else%
        {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
        \fi
    }%
    \vskip-1ex%
    \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
  \end{beamercolorbox}%
}

\defbeamertemplate{frametitle}{imagetitle}[1]{%
    \vspace*{-1cm}%
    \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
    \@tempdima=\textwidth%
    \advance\@tempdima by\beamer@leftmargin%
    \advance\@tempdima by\beamer@rightmargin%
    \begin{beamercolorbox}[sep=0.3cm,left,wd=\the\@tempdima]{frametitle}
        \usebeamerfont{frametitle}%
        \vbox{}\vskip-1ex%
        \if@tempswa\else\csname beamer@fteleft\endcsname\fi%
        \strut\insertframetitle\strut\par%
        {%
            \ifx\insertframesubtitle\@empty%
            \else%
            {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
            \fi
        }%
        \vskip-1ex%
        \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
    \end{beamercolorbox}%
    \begin{tikzpicture}[remember picture,overlay]
        \node[anchor=north east,yshift=2pt] at (current page.north east) {\includegraphics[height=0.8cm]{#1}};
    \end{tikzpicture}   
}

\BeforeBeginEnvironment{frame}{%
    \setbeamertemplate{frametitle}[mydefault]%
}

\define@key{beamerframe}{imagetitle}[true]{%
    \setbeamertemplate{frametitle}[imagetitle]{#1}%
}
\makeatother

\begin{document}

    \begin{frame}
        \frametitle{bla}
        no logo
    \end{frame} 

    \begin{frame}[imagetitle=example-grid-100x100bp.pdf]
        \frametitle{bla}
        logo
    \end{frame}

    \begin{frame}[imagetitle=example-image.pdf]
        \frametitle{bla}
        \framesubtitle{blub}
        another logo
    \end{frame} 

    \begin{frame}
        \frametitle{bla}
        \framesubtitle{blub}
        no logo
    \end{frame}

\end{document}
  • in your example you use one 1 logo for each frame. Is it possible to show more than one? – wiso Aug 20 '15 at 23:54

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.