如何在 beamer 主文件中定义用于主题的附加信息命令?

如何在 beamer 主文件中定义用于主题的附加信息命令?

在典型的 beamer 文档中,我可以设置各种选项,\author例如\title

主文本

\documentclass{beamer}

\author{George Orwell}
\title{Animal Farm}
\date{\today}
\institute[TUD]
%\def\talklocation{Berlin}

\usetheme{tudrobert}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\end{document}

然后可以在模板定义中使用它:

beamerthemetudrobert.tex

\mode<presentation>

\usepackage{graphicx}
\usepackage[absolute,overlay]{textpos}
\usepackage{calc}

\usepackage{fontspec}
\useinnertheme{tudrobert}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]  

\mode<all>

最后我想要使用命令的主题是:

beamerinnerthemetudrobert.tex

\mode<presentation>

\defbeamertemplate*{title page}{tudrobert}{%

    \usebeamerfont*{title}
    \MakeUppercase{\inserttitle}\par
    \vfill
    {\scriptsize\insertauthor}
    \vfill
    \vfill
    %\talklocation, \insertdate

}

\mode<all>

建议使用

\def\talklocation{Berlin}

\talklocation

抛出错误

在此处输入图片描述

同样适用于

\newcommand{\talklocation}{Berlin}

添加附加属性/字符串以传递给主题的适当方法是什么?

答案1

正如 Jojo Boulix 在评论中所建议的那样投影机选项才是正确答案。

这三个文件可能如下所示:

主文本

\documentclass{beamer}

\author{George Orwell}
\title{Animal Farm}
\date{\today}
\institute[TUD]

\usetheme[location=Berlin]{tudrobert}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\end{document}

beamerthemetudrobert.tex

\mode<presentation>

\DeclareOptionBeamer{location}{\PassOptionsToPackage{location=#1}{beamerinnerthemetudrobert}}
\DeclareOptionBeamer{conference}{\PassOptionsToPackage{conference=#1}{beamerinnerthemetudrobert}}
\ProcessOptionsBeamer

\usepackage{graphicx}
\usepackage[absolute,overlay]{textpos}
\usepackage{calc}

\usepackage{fontspec}
\useinnertheme{tudrobert}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]  

\mode<all>

beamerinnerthemetudrobert.tex

\mode<presentation>

\DeclareOptionBeamer{location}{\def\beamer@tudrobert@location{#1}}    
\DeclareOptionBeamer{conference}{\def\beamer@tudrobert@conference{#1}}    
\ProcessOptionsBeamer

\defbeamertemplate*{title page}{tudrobert}{%

    \usebeamerfont*{title}
    \MakeUppercase{\inserttitle}\par
    \vfill
    {\scriptsize\insertauthor}
    \vfill
    \vfill
    \beamer@tudrobert@location, \insertdate
    \beamer@tudrobert@conference

}

\mode<all>

相关内容