在这和这个问题我学会了如何传递简单的定义,比如地点从我的主文件到例如beameroutertheme。
然而,这种方法对于较长的字符串或文本块无效,在本例中
“你好世界!”
主文本
\documentclass{beamer}
\author{George Orwell}
\title{Animal Farm}
\date{\today}
\institute[TUD]
\usetheme[myText=Hello World!]{tudrobert}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}
然后可以在模板定义中使用它:
beamerthemetudrobert.tex
\mode<presentation>
\DeclareOptionBeamer{myText}{\PassOptionsToPackage{myText=#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{myText}{\def\beamer@tudrobert@myText{#1}}
\ProcessOptionsBeamer
\defbeamertemplate*{title page}{tudrobert}{%
\usebeamerfont*{title}
\MakeUppercase{\inserttitle}\par
\vfill
{\scriptsize\insertauthor}
\vfill
\beamer@tudrobert@myText
\vfill
\insertdate
}
\mode<all>
如您所见,文本未被正确解析。
将主文件中定义的文本传递到 beamer 主题的适当方法是什么?
答案1
以下答案基于https://tex.stackexchange.com/a/58512/36296以及 latex.ltx 中的作者定义
主文本
\documentclass{beamer}
\usetheme[myText=Hello World!]{tudrobert}
\author{George Orwell}
\title{Animal Farm}
\date{\today}
\institute[TUD]
\def\uni{Hello World!}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}
beamerthemetudrobert.tex
\mode<presentation>
\DeclareOptionBeamer{myText}{\PassOptionsToPackage{myText=#1}{beamerinnerthemetudrobert}}
\ProcessOptionsBeamer
\usepackage{graphicx}
\usepackage[absolute,overlay]{textpos}
\usepackage{calc}
\def\uni#1{\gdef\@uni{#1}}
\def\@uni{\@latex@warning@no@line{No \noexpand\uni given}}
\useinnertheme{tudrobert}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]
\mode<all>
beamerinnerthemetudrobert.tex
\mode<presentation>
\DeclareOptionBeamer{myText}{\def\beamer@tudrobert@myText{#1}}
\ProcessOptionsBeamer
\defbeamertemplate*{title page}{tudrobert}{%
\usebeamerfont*{title}
\MakeUppercase{\inserttitle}\par
\vfill
{\scriptsize\insertauthor}
\vfill
\beamer@tudrobert@myText
\vfill
\insertdate
\vfill
\@uni
}
\mode<all>