请检查麦格
\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}
以及相应的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)}
}
问题是,我想插入序言中的图像。目前,徽标是硬编码的,如下所示example-image-a
:
\begin{flushright}
\ifnum \insertpagenumber=1
\includegraphics[width=.06\pagewidth]{example-image-a}%\hskip20pt
\else
\insertframenumber{}\hfill\vfill%
\fi
我正在尝试通过一些选项来更改它,以便我可以将序言中的图像更改为
\setlogo{example-image-b}
我怎样才能做到这一点?
我以前问过这个问题,在 setbeamertheme 中使用变量图像但答案不起作用,并且我收到了错误(确切的输出现在不在我身边)。
答案1
在您的 beamer 风格中,定义\setlogo
如下。
\newcommand\setlogo[1]{\def\@logo{#1}}
另外,将加载logo的部分改为如下代码,如果logo没有设置,则打印页码,否则打印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}%
% 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)}
}