将参数传递给 Beamer 标题页的输入文件

将参数传递给 Beamer 标题页的输入文件

我正在寻找将文本传递到用于创建 Beamer 演示文稿标题页的文件的方法。我将一个文件BeamerTitle.tex用于不同的类。

我想将“Class Topic”作为输入参数发送到 中的 BeamerTitle.tex 文件\input{BeamerTitle}。我该怎么做?

谢谢你!

MWE 如下。

BeamerTitle.tex

\title[Running Title]{\LARGE{\textbf{Title of the Course}}}

\author[Running Instructor]{%
    \textbf{Instructor Name}
    \vspace{2\baselineskip} \\
    {\Large Class Topic (as input, with same color as title)}
    \vspace{5\baselineskip} \\
    Univ info line 1 \\
    Univ info line 2 \\
    \ \\
    Semester}
\date{}
    
\begin{frame}
        \titlepage
\end{frame}

MainFile.tex

\documentclass[t]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usetheme{Boadilla}
\usecolortheme{default}

\usepackage{hyperref}
\hypersetup{
    pdftitle={Title on PDF properties},
    pdfauthor={Author on PDF properties},
    pdfsubject={Subject on PDF properties}
}

\setbeamertemplate{frametitle}{%
\begin{centering}
    \vspace{0.3cm}
    \text{\strut\insertframetitle}  % \strut to fix height of title.
    \par
\end{centering}
}

\begin{document}

\input{BeamerTitle} % Should pass parameter "Class Topic"

\section{Topic of the Class}

\begin{frame}
    \frametitle{Topic of the Class}
    \begin{itemize}
        \item Etc
        \item Etc
        \begin{itemize}
            \item Etc
            \item Etc
        \end{itemize}
    \end{itemize}
\end{frame}

\end{document}

封面

答案1

您可以将课程主题存储在宏中:

\documentclass[t]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usetheme{Boadilla}
\usecolortheme{default}

\usepackage{hyperref}
\hypersetup{
    pdftitle={Title on PDF properties},
    pdfauthor={Author on PDF properties},
    pdfsubject={Subject on PDF properties}
}

\setbeamertemplate{frametitle}{%
\begin{centering}
    \vspace{0.3cm}
    \text{\strut\insertframetitle}  % \strut to fix height of title.
    \par
\end{centering}
}


\begin{filecontents*}[overwrite]{BeamerTitle.tex}
\title[Running Title]{\LARGE{\textbf{Title of the Course}}}

\author[Running Instructor]{%
    \textbf{Instructor Name}
    \vspace{2\baselineskip} \\
    {\Large \classtopic}
    \vspace{5\baselineskip} \\
    Univ info line 1 \\
    Univ info line 2 \\
    \ \\
    Semester}
\date{}
    
\begin{frame}
        \titlepage
\end{frame}

\end{filecontents*}

\newcommand{\classtopic}{
Class Topic (as input, with same color as title)
}

\begin{document}

\input{BeamerTitle} % Should pass parameter "Class Topic"

\section{Topic of the Class}

\begin{frame}
    \frametitle{Topic of the Class}
    \begin{itemize}
        \item Etc
        \item Etc
        \begin{itemize}
            \item Etc
            \item Etc
        \end{itemize}
    \end{itemize}
\end{frame}

\end{document}

答案2

我找到了以下解决方案。我将类主题存储为稍后在 tex 文件中使用的宏。但关键在于,现在我单独定义标题页的元素,并更灵活地使用这些元素。这样,我可以使用类主题和其他与 beamer 主题颜色相同的元素。

此外,由于标题元素是在序言中定义的,因此它们并不与包冲突hyperref

主文件:

\documentclass{beamer}

\title{Course title}
\subtitle{Subtitle name}
\author{Instructor name}
\institute{Institute name}
\date{Course date}

\usepackage{hyperref}
\hypersetup{
    pdftitle={Title on PDF properties},
    pdfauthor={Author on PDF properties},
    pdfsubject={Subject on PDF properties}
}

% Class topic in title page
\newcommand{\ClassTopic}{Class Topic}

\begin{document}

\input{BeamerTitle02.tex}

\end{document}

标题文件(BeamerTitle02.tex):

\begin{frame}

\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp,rounded=true,shadow=true]{title}
    \usebeamerfont{title}\inserttitle\par%
    \ifx\insertsubtitle\@empty%
    \else%
    \vskip0.25em%
    {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
    \fi%     
\end{beamercolorbox}%

\begin{beamercolorbox}[sep=8pt,center,colsep=-4bp,rounded=true,shadow=true]{author}
    \usebeamerfont{author}\insertauthor
\end{beamercolorbox}

{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}

\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \usebeamerfont{title}{\ClassTopic}\par
\end{beamercolorbox}

\begin{center}
\insertinstitute

\insertdate
\end{center}

\end{frame}

封面

相关内容