我正在尝试使用 Beamer 突出显示带有注释的方程中的一个变量(借助此建议的自动空间调整使用 hf-tikz 编写的方程式下方的文本)。幻灯片包含带有说明性注释的 itemize 环境。这是 Beamer 的最小工作示例。
\documentclass{beamer}
\usefonttheme{professionalfonts}
\usefonttheme{serif}
\usefonttheme{structuresmallcapsserif}
\usepackage{amsmath, amssymb}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[beamer,markings]{hf-tikz}
\usepackage{mathtools,xparse} % texted arrows
\newcommand<>{\annotate}[2][]{
\onslide#3{
\tikz[remember picture,overlay]\node[#1,use marker id] at (0,0){#2};
}
}
\newlength{\notewidth}
\newcommand{\setnotewidth}[1]{%
\settowidth{\notewidth}{$#1$}%
}
\newcommand{\mth}[2]{
\setnotewidth{#2}
\mathmakebox[0.100\notewidth]{#1}
}
\NewDocumentCommand{\tikzmarkaligned}{r<> o m m}{
\phantom{\mth{#3}{#4}}
\tikzmarkin<#1>[#2]{#3}#3\tikzmarkend{#3}
\phantom{\mth{#3}{#4}}
}
\def\savepointas#1#2{%
\expandafter\gdef\csname save@pt@#1\endcsname{#2}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\indentdisplays[1]{%
\everydisplay{\addtolength\displayindent{#1}%
\addtolength\displaywidth{-#1}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}
\transwipe
\begin{itemize}
\item<1->[]{ \indentdisplays{-3em} \begin{equation} \mathbf{pb_{i,\,t}} = \underbrace{\gamma_{i}~\{~+\delta_{t}\}}_{\textrm{fixed effects}} + \alpha \cdot pb_{i,\,t-1} +
\tikzmarkaligned<1->[mark at=0.825]{\beta_{0 (t)}}{\beta_{0\,(t)} \gg 0}
\annotate<1->[below,black,font=\scriptsize]{$\beta_{0\,(t)} \gg 0$}~\cdot~d_{i,\,t-1} \mathbf{\vartheta_{i,\,t}}, \end{equation} }
\begin{itemize}
\item<1->{$ pb_{i,\,t} = \tau_{i,\,t} - g_{i,\,t} - ir_{i,\,t}$}
\item<2->{}
\item<2->[]{ \setbeamercolor{postit}{fg=black,bg=gray!10} \begin{beamercolorbox}[\vskip -1.35em,\hskip 0.0em,wd=\linewidth,rounded=true,shadow=true]{postit} {\textbf{\emph{Sufficient}} but not necessary condition} \end{beamercolorbox}}
\end{itemize}
\end{itemize}
\end{frame}
\end{document}
它适用于错误消息
缺少插入的 \endcsname。\end{frame}。
如果我使用任何希腊字母和/或诸如\
这样的表达方式\,
,则会出现另一条错误消息
缺少插入的 \endcsname。\savepointas...
然后,彩色框没有调整,方程的一部分缺失。
由于我现在要使用tikz
,我可能缺少对象的定义。欢迎提出任何建议。
答案1
这里有两个问题。
- 第一个是
beamercolorbox
显然不喜欢将间距指令传递到广告选项。这些应该放在 之前\begin
。 - 第二个是在 的定义中
\tikzmarkaligned
。我将从这个列表里讨论它。
让我们回顾一下序言的部分内容:
\newcommand{\mth}[2]{
\setnotewidth{#2}
\mathmakebox[0.100\notewidth]{#1}
}
\NewDocumentCommand{\tikzmarkaligned}{r<> o m m}{
\phantom{\mth{#3}{#4}}
\tikzmarkin<#1>[#2]{#3}#3\tikzmarkend{#3}
\phantom{\mth{#3}{#4}}
}
现在我不知道\tikzmarkin
和\tikzmarkend
宏到底是做什么的。根据hf-tikz
文档,它们插入彩色区域的分隔符。但是,它们似乎不喜欢希腊字母。因此,将#3
两者输入都是自找麻烦,因为#3
应该是彩色的。最好的办法是,在排版#4
时设置着色宽度,将其输入这两个宏,然后#3
用不会引起麻烦且宽度大致正确的随机类型字符串填充它,即与的宽度相同。#4
foobarbaz
#3
因此代码可以修改为:
\documentclass{beamer}
\usefonttheme{professionalfonts}
\usefonttheme{serif}
\usefonttheme{structuresmallcapsserif}
\usepackage{amsmath, amssymb}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[beamer,markings]{hf-tikz}
\usepackage{mathtools,xparse} % texted arrows
\NewDocumentCommand{\annotate}{r<>O{}m}{
\onslide#1{
\tikz[remember picture,overlay]\node[#2,use marker id] at (0,0){#3};
}
}
\newlength{\notewidth}
\newcommand{\setnotewidth}[1]{%
\settowidth{\notewidth}{$#1$}%
}
\newcommand{\mth}[2]{
\setnotewidth{#2}
\mathmakebox[0.100\notewidth]{#1}
}
\NewDocumentCommand{\tikzmarkaligned}{r<> o m m}{
\phantom{\mth{#3}{#4}}
\tikzmarkin<#1>[#2]{#4}#3\tikzmarkend{#4}
\phantom{\mth{#3}{#4}}
}
\def\savepointas#1#2{%
\expandafter\gdef\csname save@pt@#1\endcsname{#2}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\indentdisplays[1]{%
\everydisplay{\addtolength\displayindent{#1}%
\addtolength\displaywidth{-#1}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}
\transwipe
\begin{itemize}
\item<1->[]{ \indentdisplays{-3em} \begin{equation} \mathbf{pb_{i,\,t}} = \underbrace{\gamma_{i}~\{~+\delta_{t}\}}_{\textrm{fixed effects}} + \alpha \cdot pb_{i,\,t-1} +
\tikzmarkaligned<1->[mark at=0.825]{\beta_{0 (t)}}{foobarbaz}
\annotate<1->[below,black,font=\scriptsize]{$\beta_{0\,(t)} \gg 0$}~\cdot~d_{i,\,t-1} \mathbf{\vartheta_{i,\,t}}, \end{equation} }
\begin{itemize}
\item<1->{$ pb_{i,\,t} = \tau_{i,\,t} - g_{i,\,t} - ir_{i,\,t}$}
\item<2->{}
\item<2->[]{ \setbeamercolor{postit}{fg=black,bg=gray!10} \vskip -1.35em \hskip 0.0em \begin{beamercolorbox}[wd=\linewidth,rounded=true,shadow=true]{postit} {\textbf{\emph{Sufficient}} but not necessary condition} \end{beamercolorbox}}
\end{itemize}
\end{itemize}
\end{frame}
\end{document}
编译成功,结果为:
不幸的是,我不再确定这是我想要的,因为我发布的评论有一个错误的网址这个图片相反,它来自Claudio Fiandrino 的回答在这里,就像 OP 的 MWE 中的代码一样。
请注意,要调整框,必须编译两次。
在上面的评论中,我说我得到了:
包 pgf 错误:未知标记形状“标记单位向量-1”
错误。我不知道它从何而来,也不知道该如何解决。我只注意到,从错误marker id
定义中消除后,错误消失了。\annotate
更新
我发现这个等式有些问题。我意识到有一个多余的。将OP 代码中1-
的 定义更改为:\annotate
\NewDocumentCommand{\annotate}{r<>O{}m}{
\onslide#1{
\tikz[remember picture,overlay]\node[#2,use marker id] at (0,0){#3}
}
}
生成了\onslide1-
,这导致\onslide
什么都不做,并且1-
被排版。我的错。恢复到:
\newcommand<>{\annotate}[2][]{
\onslide#3{
\tikz[remember picture,overlay]\node[#1,use marker id] at (0,0){#2};
}
}
修复了这个问题。但我不知道为什么。我从未见过。显然,这是一个技巧,用于定义一个命令,该命令接受包装在as\newcommand<>
中的参数,然后像平常一样解析后面的内容。所以有as 、as和as 。<>
#3
\newcommand
\annotate<1->[…]{……}
1-
#3
…
#1
……
#2
更新\savepointas
正如我在评论中所说,我认为它根本没用,因为它从未在代码中被调用。也许它是由某个定义的命令中使用的某个包命令调用的。无论如何,我尝试了使用它和不使用它的编译。以下是代码:
\documentclass{beamer}
\usefonttheme{professionalfonts}
\usefonttheme{serif}
\usefonttheme{structuresmallcapsserif}
\usepackage{amsmath, amssymb}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[beamer,markings]{hf-tikz}
\usepackage{mathtools,xparse} % texted arrows
\newcommand<>{\annotate}[2][]{
\onslide#3{
\tikz[remember picture,overlay]\node[#1,use marker id] at (0,0){#2};
}
}
\newlength{\notewidth}
\newcommand{\setnotewidth}[1]{%
\settowidth{\notewidth}{$#1$}%
}
\newcommand{\mth}[2]{
\setnotewidth{#2}
\mathmakebox[0.100\notewidth]{#1}
}
\NewDocumentCommand{\tikzmarkaligned}{r<> o m m}{
\phantom{\mth{#3}{#4}}
\tikzmarkin<#1>[#2]{#4}#3\tikzmarkend{#4}
\phantom{\mth{#3}{#4}}
}
\def\savepointas#1#2{%
\expandafter\gdef\csname save@pt@#1\endcsname{#2}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\indentdisplays[1]{%
\everydisplay{\addtolength\displayindent{#1}%
\addtolength\displaywidth{-#1}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}
\transwipe
\begin{itemize}
\item<1->[]{ \indentdisplays{-3em} \begin{equation} \mathbf{pb_{i,\,t}} = \underbrace{\gamma_{i}~\{~+\delta_{t}\}}_{\textrm{fixed effects}} + \alpha \cdot pb_{i,\,t-1} +
\tikzmarkaligned<1->[mark at=0.825]{\beta_{0 (t)}}{foobarbaz}
\annotate<1->[below,black,font=\scriptsize]{$\beta_{0\,(t)} \gg 0$}~\cdot~d_{i,\,t-1} \mathbf{\vartheta_{i,\,t}}, \end{equation} }
\begin{itemize}
\item<1->{$ pb_{i,\,t} = \tau_{i,\,t} - g_{i,\,t} - ir_{i,\,t}$}
\item<2->{}
\item<2->[]{ \setbeamercolor{postit}{fg=black,bg=gray!10} \vskip -1.35em \hskip 0.0em \begin{beamercolorbox}[wd=\linewidth,rounded=true,shadow=true]{postit} {\textbf{\emph{Sufficient}} but not necessary condition} \end{beamercolorbox}}
\end{itemize}
\end{itemize}
\end{frame}
\end{document}
输出该\def
行:
没有它的输出:
看到有什么不同吗?我真的没看到……如果你得到不同的结果,那么你可能有一个或多个软件包的版本已过时。