2

Please check this mwe.tex

\documentclass[10pt,xcolor=dvipsnames,xcolor=table,handout]{beamer}
\definecolor{dcol}{HTML}{034da1}
\usetheme{Mwe}
\title{mwe}
\author{mwe}
\institute{mwe}
\begin{document}
\maketitle
\begin{frame}{Table of Contents}
    \tableofcontents
\end{frame}
\section{Hello}
\subsection{Hello}
\begin{frame}{Hello Title}
    Hello text
    \begin{itemize}
        \item Hello
    \end{itemize}
\end{frame}
\end{document}

and the corresponding beamerthemeMwe.sty:

\mode<presentation>
\usepackage[sfdefault]{roboto}
\usecolortheme[named=dcol]{structure}
\setbeamercolor*{palette primary}{use=structure,fg=white,bg=dcol}
\setbeamercolor*{palette quaternary}{bg=dcol,fg=white}
\setbeamercolor{normal text}{fg=dcol}

%%%%%%%%%%%%%%%%%%%%% % FOOTLINE %%%%%%%%%%%%%%%%%%%%%

\defbeamertemplate*{footline}{mat theme}{% \begin{beamercolorbox}[wd=\paperwidth,ht=0.04\paperheight,dp=2.25ex]{title in head/foot}% \begin{minipage}[c]{0.25\paperwidth}% \hskip10pt\insertshortauthor% \end{minipage}% \begin{minipage}[c]{0.60\paperwidth}% \centering \inserttitle% \end{minipage}% \begin{minipage}[t]{0.10\paperwidth}% \begin{flushright} \ifnum \insertpagenumber=1 \includegraphics[width=.06\pagewidth]{example-image-a}%\hskip20pt \else \insertframenumber{}\hfill\vfill% \fi \end{flushright} \end{minipage}% \end{beamercolorbox}% \vfill% }

\AtBeginDocument{% \pgfdeclareverticalshading{b@matshade}{\the\paperwidth} {rgb(0pt)=(1,1,1); rgb(3pt)=(0.8,0.8,0.8);rgb(5pt)=(0.75,0.75,0.75)} }

The problem is, I would like insert the image from preamble. At present, the logo is hard coded, as example-image-a:

  \begin{flushright}
      \ifnum \insertpagenumber=1
         \includegraphics[width=.06\pagewidth]{example-image-a}%\hskip20pt
       \else
         \insertframenumber{}\hfill\vfill%
      \fi

I am trying to change it, with some option, so that I can change the image in preamble as

\setlogo{example-image-b}

How I can do that?

I have asked this question before, in use variable image in setbeamertheme but the answer is not working, and I had got error (the exact output is not with me right now).

BaRud
  • 2,179

1 Answers1

2

In your beamer style, define \setlogo as follows.

\newcommand\setlogo[1]{\def\@logo{#1}}

Moreover, change the part where you load the logo to the following code. If the logo hasn't been set, it will print the page number, otherwise the logo.

\begin{minipage}[t]{0.10\paperwidth}%
    \begin{flushright}
        \ifnum \insertpagenumber=1
            \ifcsname @logo\endcsname
                \includegraphics[width=.06\paperwidth]{\@logo}%
            \else
                \insertframenumber{}\hfill\vfill
            \fi
        \else
            \insertframenumber{}\hfill\vfill
        \fi
    \end{flushright}
\end{minipage}%

enter image description here

% main.tex
\documentclass[10pt,xcolor=dvipsnames,xcolor=table,handout]{beamer}
\definecolor{dcol}{HTML}{034da1}
\usetheme{Mwe}
\setlogo{example-image-a}
\title{mwe}
\author{mwe}
\institute{mwe}
\begin{document}
\maketitle
\begin{frame}{Table of Contents}
    \tableofcontents
\end{frame}
\section{Hello}
\subsection{Hello}
\begin{frame}{Hello Title}
    Hello text
    \begin{itemize}
        \item Hello
    \end{itemize}
\end{frame}
\end{document}
% beamerthemeMwe.sty
\mode<presentation>
\usepackage[sfdefault]{roboto}
\usecolortheme[named=dcol]{structure}
\setbeamercolor*{palette primary}{use=structure,fg=white,bg=dcol}
\setbeamercolor*{palette quaternary}{bg=dcol,fg=white}
\setbeamercolor{normal text}{fg=dcol}

\newcommand\setlogo[1]{\def@logo{#1}} %%%%%%%%%%%%%%%%%%%%% % FOOTLINE %%%%%%%%%%%%%%%%%%%%%

\defbeamertemplate*{footline}{mat theme}{% \begin{beamercolorbox}[wd=\paperwidth,ht=0.04\paperheight,dp=2.25ex]{title in head/foot}% \begin{minipage}[c]{0.25\paperwidth}% \hskip10pt\insertshortauthor% \end{minipage}% \begin{minipage}[c]{0.60\paperwidth}% \centering \inserttitle% \end{minipage}% \begin{minipage}[t]{0.10\paperwidth}% \begin{flushright} \ifnum \insertpagenumber=1 \ifcsname @logo\endcsname \includegraphics[width=.06\paperwidth]{@logo}%\hskip20pt \else \insertframenumber{}\hfill\vfill \fi \else \insertframenumber{}\hfill\vfill \fi \end{flushright} \end{minipage}% \end{beamercolorbox}% \vfill% }

\AtBeginDocument{% \pgfdeclareverticalshading{b@matshade}{\the\paperwidth} {rgb(0pt)=(1,1,1); rgb(3pt)=(0.8,0.8,0.8);rgb(5pt)=(0.75,0.75,0.75)} }

gernot
  • 49,614