6

I would like to insert an additional (other than the top-left one) logo in a beamer presentation using Palo Alto theme, so that it appears in the navigation bar ONLY if there is enough space left.

What is the best way to achieve this result?

Until now, I've been able to place it to the desired position, but do not know how to let it "disapperar" instead of being uglily cut when there is not enough space for it.

Here is a minimal working example (it seems package mwe is not avaiable in my distribution, so i just created a red square image).

\documentclass{beamer}
\usetheme[hideothersubsections]{PaloAlto} 
\usecolortheme{seahorse}
\setbeamercovered{transparent}

\makeatletter
\setbeamertemplate{sidebar \beamer@sidebarside}
{
\beamer@tempdim=\beamer@sidebarwidth%
\advance\beamer@tempdim by -6pt%
{\usebeamerfont{title in sidebar}%
  \vskip1.5em%
  \hskip3pt%
  \usebeamercolor[fg]{title in sidebar}%
  \insertshorttitle[width=\beamer@tempdim,center,respectlinebreaks]\par%
  \vskip1.25em%
}%
{%
  \hskip3pt%
  \usebeamercolor[fg]{author in sidebar}%
  \usebeamerfont{author in sidebar}%
  \insertshortauthor[width=\beamer@tempdim,center,respectlinebreaks]\par%
  \vskip1.25em%
}%
\insertverticalnavigation{\beamer@sidebarwidth}%
\vfill
\ifx\beamer@sidebarside\beamer@lefttext%
\else%
  \usebeamercolor{normal text}%
  \llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}%
  \vskip2pt%
\fi%
\hskip8pt
\includegraphics[height=1cm,keepaspectratio]{example-logo}~%
\vskip2pt
}
\makeatother
\logo{\includegraphics[height=0.7cm,keepaspectratio]{example-logo}}

\begin{document} 

\section{Section1}

\frame{Test Frame 1}

\section{Section 2}
\subsection{Subsection1 is a very long-titled subsection}
\subsection{Subsection2 is a very long-titled subsection}
\subsection{Subsection3 is a very long-titled subsection}
\subsection{Subsection4 is a very long-titled subsection}
\subsection{Subsection5 is a very long-titled subsection}
\subsection{Subsection6 is a very long-titled subsection}
\subsection{Subsection7 is a very long-titled subsection}
\subsection{Subsection8 is a very long-titled subsection}
\subsection{Subsection9 is a very long-titled subsection}
\frame{test Frame 2}
\end{document}

As you can see below, while in the first frame the lower-left logo is nicely displayed, in the second one part of it is out of the frame. I want that, when this happens, the logo is simply not shown.

enter image description here

3
  • I've modified the question and added an example document. Unfortunately it seems that mwe is not avaiable in my latex distribution (i use TexMaker on Ubuntu 12.04)
    – antosecret
    Sep 30, 2012 at 12:42
  • Thank you for the MWE. Changing the image name to example-image-a makes it compilable.
    – percusse
    Sep 30, 2012 at 12:46
  • @antosecret: No problemo, that's what people with higher reputation are there for ;) Sep 30, 2012 at 13:12

1 Answer 1

2

Here's a version using TikZ to measure the picture's height and only insert it if enough space is left:

Code

\documentclass{beamer}
\usepackage{tikz}
\usepackage{xifthen}
\usetheme[hideothersubsections]{PaloAlto} 
\usecolortheme{seahorse}
\setbeamercovered{transparent}

\newcommand{\insertpic}[2][scale=1]% [options], picname
{   \begin{tikzpicture}[remember picture,overlay]
        \path (navenddummy);
        \pgfgetlastxy{\xnav}{\ynav}
        \vphantom{\hphantom{
            \node[inner sep=0pt,above right] (pictopdummy) {\includegraphics[#1]{#2}};
        }}
        \path (pictopdummy.north);
        \pgfgetlastxy{\xpic}{\ypic}
        \pgfmathtruncatemacro{\picornot}{\ypic < \ynav ? 1 : 0}
        \ifthenelse{\picornot=1}
            {\node[inner sep=0pt,above right] {\includegraphics[#1]{#2}};}
            {}
        %\node[inner sep=1pt,circle,fill=red] at (navenddummy) {};
        %\node[inner sep=1pt,circle,fill=blue] at (pictopdummy.north) {};
    \end{tikzpicture}
}

\makeatletter
\setbeamertemplate{sidebar \beamer@sidebarside}
{
\beamer@tempdim=\beamer@sidebarwidth%
\advance\beamer@tempdim by -6pt%
{\usebeamerfont{title in sidebar}%
  \vskip1.5em%
  \hskip3pt%
  \usebeamercolor[fg]{title in sidebar}%
  \insertshorttitle[width=\beamer@tempdim,center,respectlinebreaks]\par%
  \vskip1.25em%
}%
{%
  \hskip3pt%
  \usebeamercolor[fg]{author in sidebar}%
  \usebeamerfont{author in sidebar}%
  \insertshortauthor[width=\beamer@tempdim,center,respectlinebreaks]\par%
  \vskip1.25em%
}%
\insertverticalnavigation{\beamer@sidebarwidth}%
%=================
\begin{tikzpicture}[overlay,remember picture]
    \coordinate (navenddummy);
\end{tikzpicture}
%=================
\vfill
\ifx\beamer@sidebarside\beamer@lefttext%
\else%
  \usebeamercolor{normal text}%
  \llap{\usebeamertemplate***{navigation symbols}\hskip0.1cm}%
  \vskip2pt%
\fi%
\hskip8pt
%=================
\insertpic[height=0.7cm,keepaspectratio]{book.png}~
%=================
\vskip2pt
}
\makeatother
\logo{\includegraphics[height=0.7cm,keepaspectratio]{book.png}}

\begin{document} 

\section{Section1}

\frame{Test Frame 1}
\frame{test Frame 2}

\section{Section 2}
\subsection{Subsection1 is a very long-titled subsection}
\subsection{Subsection2 is a very long-titled subsection}
\subsection{Subsection3 is a very long-titled subsection}
\subsection{Subsection4 is a very long-titled subsection}
\subsection{Subsection5 is a very long-titled subsection}
\subsection{Subsection6 is a very long-titled subsection}
\subsection{Subsection7 is a very long-titled subsection}
\subsection{Subsection8 is a very long-titled subsection}
\subsection{Subsection9 is a very long-titled subsection}

\frame{test Frame 3}
\frame{test Frame 4}
\end{document}

Output

enter image description here

You must log in to answer this question.

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