Beamer 中的绝对定位,带覆盖,无 TikZ

Beamer 中的绝对定位,带覆盖,无 TikZ

更新:我已经编写了一个程序包来处理这个问题:绝对


这里已经有很多类似的问题(例如,我怎样才能使 textpos 尊重 beamer 覆盖?beamer:如何在 textblock* 环境中使用 \pause,以及很多关于绝对定位的更普遍的问题),所以让我尝试更具体地澄清我正在寻找的内容:

  1. 我想将内容放置在绝对位置,并且此内容可能包含tikzpictures 等,因此我宁愿不将其放置在 TiZ 节点(避免嵌套 TiZ 图片——而且,就此而言,还可以避免额外的编译轮次)。我可能会使用棺材等来完成大部分的放置工作,但我需要一些绝对的起点(我猜棺材不能提供?)

  2. 我希望能够不受限制地使用beamer诸如 等叠加命令\pause。特别是,我希望避免将它们的参数括在括号中(这在某些情况下确实可以解决问题)——部分原因是我将使用pseudo.sty,它相当直接地支持\pause在行间插入命令。(类似情况也适用于itemizeenumerate以及<+->。)

  3. 我宁愿不需要透明的框架背景。

我不思考任何先前的答案都可以解决这两个要求(但如果这里已经有解决方案,那就太好了 - 如果是这样,很抱歉造成干扰)。

显而易见的解决方案是使用textpos,但正如前面指出的那样(例如,在上面提到的两个问题中),它\pause与等不能很好地配合。

一个简单的 MWE 可以说明这个问题:

\documentclass{beamer}
\usepackage[absolute,overlay]{textpos}

\begin{document}
\begin{frame}
\begin{textblock*}{0pt}(0pt,0pt)
A\pause B\pause C
\end{textblock*}
\end{frame}
\end{document}

这将为您提供三张幻灯片;第一张写着“BC”,第二张写着“C”,最后一张写着“ABC”。

问题出在overlay选项上。如果删除此选项,并使用透明背景,一切就都正常了,所以从技术上来说这是一个解决方案,但正如前面提到的,我宁愿在我的解决方案中不要求这样做。

\documentclass{beamer}

\usepackage[absolute]{textpos}
\setbeamercolor{background canvas}{bg=}

\begin{document}
\begin{frame}
\begin{textblock*}{0pt}(0pt,0pt)
A\pause B\pause C
\onslide<1->
\end{textblock*}
\end{frame}

\end{document}

(这里我还添加了,\onslide<1->所以页面上的其余内容(如页码或其他内容)不会暂停。)

这是几乎我想要的,除了我想要有彩色背景的选项(或让其他人有彩色背景)。(我当然可以在绝对定位的框内自己绘制这些,但是……)

那么... 有没有什么办法可以模拟或修复这个overlay选项,或者用其他方法处理透明背景的问题 —— 或者甚至可能用完全不同的机制来实现绝对定位?(我尝试在 repo 中留下一个错误报告textpos,但该 repo 已被删除...)

答案1

我觉得我可能终于找到了解决办法。似乎只需使用atbegshiwith xcoffins(或l3coffins) 就足够了,而且可以正确完成工作。在我的代码中,我使用两个棺材:一个放在 旁边atbegshi,处于绝对位置,另一个用于逐步将内容添加到第一个棺材中,可能使用 、 等进行缩放、旋转等,并\ScaleCoffin带有\RotateCoffin可配置的偏移量等。

然而,为了说明基本功能,这里有一个简单的例子,只使用一个棺材,放在框架的中心。

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty

% xcoffins may be useful, beyond l3coffins, if you need \TotalHeight, etc.
\usepackage{xcoffins}
%\usepackage{atbegshi} % imported by beamer

\NewCoffin \CenteredCoffin

% A couple of global commands that aren't available in xcoffins:
\ExplSyntaxOn
\NewDocumentCommand \GlobalSetHorizontalCoffin { m +m } {
    \hcoffin_gset:Nn{#1}{#2}
}
\NewDocumentCommand \GlobalClearCoffin { m } {
    \coffin_gclear:N{#1}
}
\ExplSyntaxOff

% Place the coffin at a given offset from the upper left of the shipout
% box, and then clear its contents (ready for its next definition/use):
\AtBeginShipout{%
    \AtBeginShipoutUpperLeftForeground{
        \TypesetCoffin\CenteredCoffin[hc,vc](.5\pdfpagewidth,-.5\pdfpageheight)
        \GlobalClearCoffin\CenteredCoffin
    }
}

\begin{document}
\begin{frame}
\GlobalSetHorizontalCoffin \CenteredCoffin {%
    \scalebox{10}{1 \pause 2 \pause 3}%
    \onslide<1->% Reset things, so the following content isn't paused
}

\color{black!10}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit
amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam
et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est
Lorem ipsum dolor sit amet.
\end{frame}
\end{document}

最终得到的三张幻灯片如下:

1

1 2

1 2 3

相关内容