投影仪标题页的“顾问”字段包含可变数量的姓名

投影仪标题页的“顾问”字段包含可变数量的姓名

我想创建一个新命令\advisors{Advisor1}{Advisor2}...{AdvisorN}(或任何类似的变体\advisors{Advisor1,Advisor2,...,AdvisorN}),用于在投影仪演示文稿的标题内打印如下列表

    \centering
    \textbf{Advisors:}\\
    Advisor1\\
    Advisor2\\
    ...\\
    AdvisorN

这是我用于标题页的自定义投影仪模板

\setbeamertemplate{title page}{
    \vbox{}
    \vfill
    \begin{centering}
        {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}\vskip1em
        {\rmfamily\textsc{- Doctoral Disseration -}\par}\vskip1em
        \begin{beamercolorbox}[sep=8pt,center,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}%
        \vskip1em\par
        \begin{beamercolorbox}[sep=7pt,center]{author}
            \usebeamerfont{author}
            \textbf{PhD candidate:}\\
            \insertauthor
        \end{beamercolorbox}
        %%% HERE SHOULD BE PRINTED THE LIST OF ADVISORS %%%
        \begin{beamercolorbox}[sep=8pt,center]{date}
            \usebeamerfont{date}\insertdate
        \end{beamercolorbox}
    \end{centering}
    \vfill
}

你能帮助我吗?

答案1

最简单的方法是定义两个宏

\newcommand*{\@advisors}{}
\newcommand*{\advisors}[1]{\def\@advisors{#1}}

并在标题页的某处添加以下几行

\ifx\@advisors\@empty\else
\par\medskip\textbf{Advisors:}\par\def\and{\par}\@advisors
\fi

完整的 MWE,我在其中包含了顾问beamercolorbox

\documentclass{beamer}

\makeatletter

\newcommand*{\@advisors}{}
\newcommand*{\advisors}[1]{\def\@advisors{#1}}

\setbeamertemplate{title page}{
    \vbox{}
    \vfill
    \begin{centering}
        {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}\vskip1em
        {\rmfamily\textsc{- Doctoral Disseration -}\par}\vskip1em
        \begin{beamercolorbox}[sep=8pt,center,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}%
        \vskip1em\par
        \begin{beamercolorbox}[sep=7pt,center]{author}
            \usebeamerfont{author}
            \textbf{PhD candidate:}\par
            \insertauthor
            \ifx\@advisors\@empty\else                                  % ADDED
            \par\medskip\textbf{Advisors:}\par\def\and{\par}\@advisors  % ADDED
            \fi                                                         % ADDED
        \end{beamercolorbox}
        \begin{beamercolorbox}[sep=8pt,center]{date}
            \usebeamerfont{date}\insertdate
        \end{beamercolorbox}
    \end{centering}
    \vfill
}
\makeatother

\author{Me Myself}
\title{My Work}
\advisors{First Advisor\and Second Advisor}

\begin{document}

\begin{frame}

\maketitle

\end{frame}

\end{document}

在此处输入图片描述

代码的实际输出当然取决于模板的其余部分。

相关内容