Beamer-标题页覆盖?

Beamer-标题页覆盖?

我想在我的 Beamer 演示文稿的标题页上添加一个覆盖层。更具体地说,我想有两个可以切换的标题版本(一个英文版,一个德文版)。最理想的情况是,周围的框和该框架的其余部分不会改变(发生移动)。

该文件的示意图如下:

\documentclass{beamer}
\mode<presentation>
{
  \usetheme{Madrid}
}
%more setup stuff

\title[]{Title A}
%\title[]{Title B}

\begin{document}
  \begin{frame}
    \titlepage
    %some logos etc. 
  \end{frame}
\end{document}

现在我的目标是让一张幻灯片带有“标题 A”,另一张幻灯片带有“标题 B”,就像我在普通幻灯片上使用叠加规范一样。有没有办法在 beamer 中做到这一点?


编辑:

这是一个明确的例子,两个标题的长度不同,并且周围的标题框不应发生变化。请参阅下面的讨论。

\title[]{%
\only<1>{This is a rather short title}%
\only<2>{Und dies ist eine deutlich längere Version, die sich über mehrere Zeilen erstreckt}%
}

如果不进行任何特殊处理,标题的高度就会有所不同,并且切换时框架的其余部分会发生变化。

答案1

您可以\only在内部使用\title

\documentclass{beamer}
\mode<presentation>
{
  \usetheme{Madrid}
}

\title[]{\only<1>{Title A}\only<2>{Title B}}

\begin{document}
  \begin{frame}
    \titlepage
    %some logos etc. 
  \end{frame}
\end{document}

\makeatletter编辑:这是修改后的版本,其中标题有不同的长度和不同的高度;和之间的所有代码\makeatother都是由 Martin Scharrer 在他的回答中编写的Beamer alt 命令“喜欢可见”而不是“喜欢仅”(所有功劳都归功于他和 Matthew Leingang 向我指出了这一点)。我添加的唯一修改是使用\parboxes 的新命令并允许标题采用不同的垂直对齐方式。

\documentclass{beamer}
\mode<presentation>
{
  \usetheme{Madrid}
}

% all the code between \makeatletter and \makeatother is from Martin Scharrer
% in https://tex.stackexchange.com/questions/13793/beamer-alt-command-like-visible-instead-of-like-only/13830#13830
\makeatletter
% Detect mode. mathpalette is used to detect the used math style
\renewcommand<>\Alt[2]{%
    \begingroup
    \ifmmode
        \expandafter\mathpalette
        \expandafter\math@Alt
    \else
        \expandafter\make@Alt
    \fi
    {{#1}{#2}{#3}}%
    \endgroup
}

% Un-brace the second argument (required because \mathpalette reads the three arguments as one
\newcommand\math@Alt[2]{\math@@Alt{#1}#2}

% Set the two arguments in boxes. The math style is given by #1. \m@th sets \mathsurround to 0.
\newcommand\math@@Alt[3]{%
    \setbox\z@ \hbox{$\m@th #1{#2}$}%
    \setbox\@ne\hbox{$\m@th #1{#3}$}%
    \@Alt
}

% Un-brace the argument
\newcommand\make@Alt[1]{\make@@Alt#1}

% Set the two arguments into normal boxes
\newcommand\make@@Alt[2]{%
    \sbox\z@ {#1}%
    \sbox\@ne{#2}%
    \@Alt
}

% Place one of the two boxes using \rlap and place a \phantom box with the maximum of the two boxes
\newcommand\@Alt[1]{%
    \alt#1%
        {\rlap{\usebox0}}%
        {\rlap{\usebox1}}%
    \setbox\tw@\null
    \ht\tw@\ifnum\ht\z@>\ht\@ne\ht\z@\else\ht\@ne\fi
    \dp\tw@\ifnum\dp\z@>\dp\@ne\dp\z@\else\dp\@ne\fi
    \wd\tw@\ifnum\wd\z@>\wd\@ne\wd\z@\else\wd\@ne\fi
    \box\tw@
}

% syntax: \AltTitl[<position>]{<TitleA>}{<TitleA>}. Posible values for <position are> c,t,b
% default: c
\newcommand\AltTitle[3][c]{%
  \Alt<2>{\parbox[#1]{.8\textwidth}{\Large\centering#2}}{\parbox[#1]{.8\textwidth}{\Large\centering#3}}
}
\makeatother

\title{\AltTitle[t]{Short Title A}{This is a really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really long Title B}}
\begin{document}

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

\end{document}

相关内容