我在 Beamer 演示文稿中有一个图形。我想逐步更改 TikZ 框的内容,并且框本身也应该是一个步骤。这有点奏效,但我收到了一条错误消息。所以我想知道如何正确地做到这一点。日志:
!软件包 tikz 错误:放弃此路径。您忘记了分号吗?。
! 您不能在受限水平模式下使用“\lastskip”。
MWE(可能有点大,但你会看到我试图完成的事情):
\documentclass[14pt,compress]{beamer}
\usepackage{pgf,pgfplots,pgfpages,tikz,tikzsymbols}
\usetikzlibrary{positioning,shapes,calc,decorations.pathreplacing}
\tikzstyle{matnode} = [inner sep=0pt,outer
sep=0pt,anchor=base,remember picture]
\begin{document}
\begin{frame}{Balance sheet of firm}
\begin{tikzpicture}[remember picture,overlay]
\tikzstyle{sboxdef} = [ font={\small}, right=1cm,text width=2.1cm, rounded corners, inner sep=1ex, draw=black];
% Draw lines and titles for balance sheet
\node (start) at ($ (current page.south)!.85!(current page.north) $) {};
\node (end) at ($ (current page.south)!.20!(current page.north) $) {};
\node[shift={(-3.5cm,-0.5cm)}](Hstart) at ($ (current page.south)!.80!(current page.north) $) {};
\node[shift={(3.5cm,-0.5cm)}](Hend) at ($ (current page.south)!.80!(current page.north) $) {};
\draw[-,thick] (start) -- (end);
\draw[-,thick] (Hstart) -- (Hend);
\node[shift={(1.5cm,0.5cm)}](Htext1) at (Hstart){\textbf{Assets}};
\node[shift={(-1.5cm,0.5cm)}](Htext2) at (Hend){\textbf{Financed}};
% Content of asset-side of balance sheet.
% I need the first onslide because in the original slide I had more stuff prior to this.
% I need onslide inside in order to take up space so that boxes remain the same (I think)
\onslide<1->{
\node[shift={(-4.1cm,1.3cm)}](SAssets) at (current page.center)[sboxdef, text height=0.7cm, fill=red!20]{
\onslide<1>{\textbf{Short\\ Assets}}\only<2->{\textbf{2573}}
};
\node[shift={(-4.1cm,-0.9cm)}](LAssets) at (current page.center)[sboxdef, text height=1.5cm, fill=red!20]{
\onslide<1>{\textbf{Long\\ Assets}}\only<2->{\textbf{3876}}
};
}
\end{tikzpicture}
\end{frame}
\end{document}
答案1
问题出在\onslide
命令上,我已修复该命令。我还利用这个机会清理了它,\tikzstyle
用相应的\tikzset
语法替换了它,并提醒您注意\usetikzlibrary{overlay-beamer-styles}
为这些事情而制作的。
\documentclass[14pt,compress]{beamer}
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
\usetikzlibrary{positioning,shapes,calc,decorations.pathreplacing}
\tikzset{matnode/.style={inner sep=0pt,outer
sep=0pt,anchor=base,remember picture}}
\begin{document}
\begin{frame}{Balance sheet of firm}
\begin{tikzpicture}[remember picture,overlay]
\tikzset{sboxdef/.style={font={\small}, right=1cm,text width=2.1cm, rounded
corners, inner sep=1ex, draw=black}}
% Draw lines and titles for balance sheet
\node (start) at ($ (current page.south)!.85!(current page.north) $) {};
\node (end) at ($ (current page.south)!.20!(current page.north) $) {};
%
\node[shift={(-3.5cm,-0.5cm)}](Hstart) at ($ (current page.south)!.80!(current page.north) $) {};
\node[shift={(3.5cm,-0.5cm)}](Hend) at ($ (current page.south)!.80!(current page.north) $) {};
%
\draw[-,thick] (start) -- (end);
\draw[-,thick] (Hstart) -- (Hend);
%
\node[shift={(1.5cm,0.5cm)}](Htext1) at (Hstart){\textbf{Assets}};
\node[shift={(-1.5cm,0.5cm)}](Htext2) at (Hend){\textbf{Financed}};
%
% % Content of asset-side of balance sheet.
% % I need the first onslide because in the original slide I had more stuff prior to this.
% % I need onslide inside in order to take up space so that boxes remain the same (I think)
\node[shift={(-4.1cm,1.3cm)},visible
on=<1->,align=center](SAssets) at (current page.center)[sboxdef,
text height=0.7cm, fill=red!20]{%
\only<1>{\textbf{Short}\\ \textbf{Assets}}\only<2->{\textbf{2573}}
};
\node[shift={(-4.1cm,-0.9cm)},visible
on=<1->,align=center](LAssets) at (current page.center)[sboxdef,
text height=1.5cm, fill=red!20]{%
\only<1>{\textbf{Long}\\ \textbf{Assets}}\only<2->{\textbf{3876}}
};
\end{tikzpicture}
\end{frame}
\end{document}