TeX - LaTeX Asked by Dr Krishnakumar Gopalakrishnan on July 5, 2021
I am using the Beamer theme Focus. I’d like to insert a logo in the top-right of every slide (i.e. frame) that contains a frame title (ie. not a plain slide). I have tried a lot of hacks and frustrated at the inflexibility of hand-tuning co-ordinates for placing my image at the desired location. (All that I want is to place the image at the top-right).
For now, we may assume that I’d like to insert a generic cat picture from the www. I’d relly appreciate a solution for this problem.
Here’s an MWE for starters
documentclass{beamer}
usetheme{focus}
title{Focus: A Minimalist Beamer Theme}
subtitle{Subtitle}
author{Author 1texorpdfstring{}{,} Author 2}
titlegraphic{includegraphics[scale=1.25]{focuslogo.pdf}}
institute{Institute Name Institute Address}
date{dd mm yyyy}
begin{document}
begin{frame}
maketitle
end{frame}
% Use starred version (e.g. section*{Section name})
% to disable (sub)section page.
section{Section 1}
subsection{Subsection 1.1}
begin{frame}{Simple frame}
This is a simple frame.
end{frame}
begin{frame}[plain]{Plain frame}
This is a frame with plain style and it is numbered.
end{frame}
subsection{Subsection 1.2}
begin{frame}[t]
This frame has an empty title and is aligned to top.
end{frame}
begin{frame}[noframenumbering]{No frame numbering}
This frame is not numbered and is citing reference cite{knuth74}.
end{frame}
begin{frame}{Typesetting and Math}
The packages texttt{inputenc} and texttt{FiraSans}footnote{url{https://fonts.google.com/specimen/Fira+Sans}}textsuperscript{,}footnote{url{http://mozilla.github.io/Fira/}} are used to properly set the main fonts.
vfill
This theme provides styling commands to typeset emph{emphasized}, alert{alerted}, textbf{bold}, textcolor{example}{example text}, dots
vfill
texttt{FiraSans} also provides support for mathematical symbols:
begin{equation*}
e^{ipi} + 1 = 0.
end{equation*}
end{frame}
end{document}
So the task is to have a logo on every frame where the frametitle
is actually typeset. Let's have a look into the theme what it does and where it defines it.
Normally frametitles are defined in the outer theme, therefore let's have a look into beamerouterthemefocus.sty
, which defines two named templates for the frametitle
:
defbeamertemplate*{frametitle}{focus}{%
defbeamertemplate*{frametitle}{plain}{%
Later in the same file, we can see that focus
is used for every frame that is not the first frame or where plain
was set:
BeforeBeginEnvironment{frame}{%
stepcounter{realframenumber}
setbeamertemplate{background canvas}[focus]%
setbeamertemplate{frametitle}[focus]%
and
define@key{beamerframe}{plain}[true]{%
setbeamertemplate{background canvas}[focusplain]%
setbeamertemplate{frametitle}[plain]%
So just setting the frametitle
through setbeamertemplate
or using addtobeamertemplate
will do no good, as on the next frame, frametitle
will be redefined to focus
. But defbeamertemplate*{frametitle}{focus}
won't work either. So how can we overcome this?
Well there is a trick explained in How to redefine a beamer template which basically is to let beamer
think, focus
is not yet defined for frametitle
.
The rest is easy, we can make use of beamer with it`s feature to reference the current page and the only drawback is that you have to compile multiple times. Our final result of the lines to add is hence:
expandafterletcsname beamer@@tmpop@frametitle@focusendcsnamerelax
defbeamertemplate*{frametitle}{focus}{%
% If not title page.
ifnumvalue{realframenumber}>0%
vspace{-1pt}%
begin{beamercolorbox}[wd=paperwidth,leftskip=0.55cm,rightskip=0.55cm,sep=0.2cm]{frametitle}%
strutinsertframetitlestrut%
end{beamercolorbox}%
fi%
begin{tikzpicture}[remember picture,overlay]
node[anchor=north east] at (current page.north east){includegraphics[width=1.6cm]{example-image-16x9}};
end{tikzpicture}
}
Just add this before the begin{document}
and you will get:
Correct answer by TobiBS on July 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP