在這和這個問題我學會如何傳遞簡單的定義,例如地點從我的主文件到例如投影機外部主題。
然而,在本例中,這種方法對於較長的字串或文字區塊會失敗
“你好世界!”
主文件
\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>
如您所見,文字未正確解析。
將主文件中定義的文字傳遞到投影機主題的適當方法是什麼?
答案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>