嗨,我正在从头开始构建一个新的 Beamer 主题。我想在主题中定义一个选项,在其中我可以定义会议名称,该名称随后可用于脚注。到目前为止,我已经完成了以下工作。在主主题中,我已定义
\DeclareOptionBeamer{conference}{\PassOptionsToPackage{conference=#1}{beamerouterthememytheme}}
并在beameroutermytheme.sty
我定义了以下内容
\def\beamer@mytheme@conference{}
\DeclareOptionBeamer{conference}{\def\beamer@mytheme@conference{#1}}
在脚注中我做了以下事情
\defbeamertemplate*{footline}{mytheme}[1]{
\begin{beamercolorbox}[ht=0.15\paperwidth,leftskip=.3cm,rightskip=.3cm,sep=0.1cm]{footlinecolor}
\usebeamerfont{section in head/foot}%
\insertshortauthor~-~\@date~-~\beamer@mytheme@conference \hfill
\insertframenumber{}/\inserttotalframenumber{}
\end{beamercolorbox}%
}
不幸的是它不起作用虽然我不明白为什么。
有什么建议吗?
按照要求,我尝试提供一个工作示例。实际上,我希望它能工作,因为我已经为所有内部、外部、颜色和主主题做了定义。无论如何,文件主题 beamerthemeMytheme.sty 听起来像
\mode<presentation>
\RequirePackage{pgf}
\DeclareOptionBeamer{conference}{\PassOptionsToPackage{conference=#1}{beamerouterthememytheme}}
\DeclareOptionBeamer{pageofpages}
{\PassOptionsToPackage{pageofpages=#1}
{beamerouterthememytheme}}
\ProcessOptionsBeamer
\useoutertheme{mytheme}
\mode
<all>
文件 beameroutermytheme.sty 听起来像
\mode<presentation>
\RequirePackage{pgf}
% efda colors
\definecolor{eblue}{rgb}{.258,.38,0.63}
\definecolor{e2blue}{rgb}{0.411,0.521,0.709}
% horizontal shading for footer
\pgfdeclarehorizontalshading{beamer@topshade}{\paperwidth}{%
color(0pt)=(eblue);
color(0.5\paperwidth)=(eblue!50);
color(\paperwidth)=(e2blue!50)}
% define the heigth of the footer
\newlength{\beamer@mytheme@headheight}
\setlength\beamer@mytheme@headheight{0.13\paperwidth}
%for date definition
\def\date#1{\def\@date{#1}}
% for page counting
\def\beamer@mytheme@pageofpages{of}
\DeclareOptionBeamer{pageofpages}
{\def\beamer@mytheme@pageofpages{#1}}
\ExecuteOptionsBeamer{pageofpages=of}
\ProcessOptionsBeamer
\def\beamer@mytheme@conference{}
\DeclareOptionBeamer{conference}{\def\beamer@mytheme@conference{#1}}
\defbeamertemplate*{footline}{mytheme}[1]
{%
\begin{pgfpicture}{0pt}{0pt}{\paperwidth}
{0.3\beamer@mytheme@headheight}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}
{0.3\beamer@mytheme@headheight}} \pgfusepath{clip}
\pgftext [ left , base ]{\pgfuseshading{beamer@topshade}}
\end{pgfpicture}
\vskip-0.3\beamer@mytheme@headheight
\begin{beamercolorbox} [ht=0.3\beamer@mytheme@headheight,leftskip=.3cm,rightskip=.3cm,sep=0.1cm]{footlinecolor}
\usebeamerfont{section in head/foot}%
\insertshortauthor~-~\@date~-~\beamer@mytheme@conference \hfill
\insertframenumber{}\hskip1pt\beamer@mytheme@pageofpages{}
\hskip1pt\inserttotalframenumber{}
\end{beamercolorbox}%
}
最后的例子如下
\documentclass[12pt]{beamer}
\usetheme[conference=Prova]{mytheme}
\title[Prova]{Prova}
\author[myself]{Io}
\date{\today}
\begin{document}
\begin{frame}{Prerequisites \& Goals}
\begin{block}{LaTeX}
\begin{itemize}
\item Obviously some basic LaTeX knowledge is necessary
\item Some more features will be provided here
\end{itemize}
\end{block}
\end{frame}
\end{document}
答案1
假设你将主文件命名为beamerthemeX.sty
。你将选项设置为:
\DeclareOptionBeamer{conference}{\PassOptionsToPackage{conference=#1}{beamerouterthemeX}}
\ProcessOptionsBeamer
然后在你的beamerouterthemeX.sty
:
\DeclareOptionBeamer{conference}{\def\beamer@X@conference{#1}}
\ProcessOptionsBeamer
最初定义选项,而对于footline
:
\defbeamertemplate*{footline}{X theme}[1]{
\begin{beamercolorbox}[ht=0.15\paperwidth,leftskip=.3cm,rightskip=.3cm,sep=0.1cm]{Location bar}
\usebeamerfont{section in head/foot}%
\insertshortauthor~-~\@date~-~\beamer@X@conference \hfill
\insertframenumber{}/\inserttotalframenumber{}
\end{beamercolorbox}%
}
现在您的presentation.tex
意愿是:
\usetheme[conference=Name]{X}