我在使用 tikz 和 beamer 时遇到了一些问题。图形每次在第二帧之后都会崩溃。我已经尝试过 onslide、pasue 和 only。没有暂停等,TikZ 图片可以正常工作...
有人能帮我一下吗?
祝好 Alex
抱歉代码混乱
\documentclass[aspectratio=169,xcolor=table]{beamer}
% Define block styles
\usepackage[ngerman]{babel}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{shapes.geometric}% für Ellipse
\usetikzlibrary{calc}
\tikzset{
pfeil/.style={stealth-},
beschr/.style={remember picture,overlay,font=\small}}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usepackage{tikz}
\usetikzlibrary{snakes}
\begin{document}
\begin{frame}
\usetikzlibrary{arrows, arrows.meta, calc, positioning, shapes}
\tikzstyle{block} = [rectangle, draw, fill=white!20,
text width=3cm, text centered, rounded corners, minimum height=2.1cm]
\tikzstyle{block1} = [rectangle, draw, fill=gray!10,
text width=3.2cm, text centered, rounded corners, minimum height=2.1cm]
\tikzstyle{block2} = [rectangle, draw, fill=gray!20,
text width=3.2cm, text centered, rounded corners, minimum height=2.1cm]
\tikzstyle{block3} = [rectangle, draw, fill=gray!25,
text width=3.4cm, text centered, rounded corners, minimum height=2.1cm]
\tikzstyle{line} = [draw, -latex']
\centering
{\begin{tikzpicture}[node distance = 0.4cm, auto]
\footnotesize
% Place nodes
\only<1>{
\node [block] (Messdaten) {\textbf{Start: ..}};
}
\only<1-2>{
\node [block1, right =of Messdaten] (Maxima) {Unterteilung...}; \path [line] (Messdaten.east) -- (Maxima);
}
\only<1-3>{
\node [block2, right =of Maxima] (SdkF) {Summe der kleinsten Fehlerquadrate....}; \path [line] (Maxima.east) -- (SdkF);
}
\only<1-4>{
\node [block3, right =of SdkF] (BSpline) {\textit{B-Spline Approximation}}; \path [line] (SdkF.east) -- (BSpline);
}
\only<1-5>{
\node [block2, below =of Messdaten] (Phasenv) {Elimination}; \path [line] (BSpline.south) -- ++(0,-5.5pt) -| (Phasenv);
}
\only<1-6>{
\node [block1, right =of Phasenv] (Aufsp) {Unterteilung ..}; \path [line] (Phasenv.east) -- (Aufsp);
}
\only<1-7>{
\node [block1, right =of Aufsp] (Minima) {Suche ..}; \path [line] (Aufsp.east) -- (Minima);
}
\only<1-8>{
\node [block, right =of Minima] (Rissschl) {\textbf{Ende..}}; \path [line] (Minima.east) -- (Rissschl);
}
\end{tikzpicture}
}
\end{frame}
\end{document}
答案1
您必须加载positioning
库才能使用=of
语法
\documentclass[aspectratio=169,xcolor=table]{beamer}
% Define block styles
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{shapes.geometric}% für Ellipse
\usetikzlibrary{calc}
\tikzset{
pfeil/.style={stealth-},
beschr/.style={remember picture,overlay,font=\small}}
%\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{snakes}
\begin{document}
\begin{frame}
\usetikzlibrary{arrows, arrows.meta, calc, positioning, shapes}
\tikzset{
block/.style={rectangle, draw, fill=white!20, text width=3cm, text centered, rounded corners, minimum height=2.1cm},
block1/.style={rectangle, draw, fill=gray!10, text width=3.2cm, text centered, rounded corners, minimum height=2.1cm},
block2/.style={rectangle, draw, fill=gray!20, text width=3.2cm, text centered, rounded corners, minimum height=2.1cm},
block3/.style={rectangle, draw, fill=gray!25, text width=3.4cm, text centered, rounded corners, minimum height=2.1cm},
line/.style={draw, -latex'}
}
\centering
{\begin{tikzpicture}[node distance = 0.4cm, auto]
\footnotesize
% Place nodes
\only<1>{
\node [block] (Messdaten) {\textbf{Start: ..}};
}
\only<1-2>{
\node [block1, right =of Messdaten] (Maxima) {Unterteilung...}; \path [line] (Messdaten.east) -- (Maxima);
}
\only<1-3>{
\node [block2, right =of Maxima] (SdkF) {Summe der kleinsten Fehlerquadrate....}; \path [line] (Maxima.east) -- (SdkF);
}
\only<1-4>{
\node [block3, right =of SdkF] (BSpline) {\textit{B-Spline Approximation}}; \path [line] (SdkF.east) -- (BSpline);
}
\only<1-5>{
\node [block2, below =of Messdaten] (Phasenv) {Elimination}; \path [line] (BSpline.south) -- ++(0,-5.5pt) -| (Phasenv);
}
\only<1-6>{
\node [block1, right =of Phasenv] (Aufsp) {Unterteilung ..}; \path [line] (Phasenv.east) -- (Aufsp);
}
\only<1-7>{
\node [block1, right =of Aufsp] (Minima) {Suche ..}; \path [line] (Aufsp.east) -- (Minima);
}
\only<1-8>{
\node [block, right =of Minima] (Rissschl) {\textbf{Ende..}}; \path [line] (Minima.east) -- (Rissschl);
}
\end{tikzpicture}
}
\end{frame}
\end{document}